我正在尝试使用 Flying Saucer 从 xhtml 生成 pdf 文件你知道为什么这段代码总是抛出异常吗?
import org.xhtmlrenderer.pdf.ITextRenderer
import com.lowagie.text.DocumentException
private void testconfiguration(String taskId) throws IOException, DocumentException {
String inputFile = "/home/marcin/firstdoc.xhtml";
String url = new File(inputFile).toURI().toURL().toString();
String outputFile = "/home/marcin/firstdoc.pdf";
OutputStream os = new FileOutputStream(outputFile);
ITextRenderer renderer = new ITextRenderer();
renderer.setDocument(url);
renderer.layout();
renderer.createPDF(os); // this line generates Exception
os.close();
}