0

我正在尝试使用 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();
}
4

1 回答 1

1

您的类路径中可能有两个不兼容的库版本(即xhtmlrenderer 库可能需要一个不是您正在使用的lowagie 库版本)。

于 2012-05-22T17:06:12.753 回答