Java 生成pdf文件时出现问题

Java 生成pdf文件时出现问题,java,flying-saucer,Java,Flying Saucer,我正在尝试使用flyingdiscer从xhtml生成pdf文件,你知道为什么这段代码总是出现x异常吗 import org.xhtmlrenderer.pdf.ITextRenderer import com.lowagie.text.DocumentException private void testconfiguration(String taskId) throws IOException, DocumentException { String inputFile = "/

我正在尝试使用flyingdiscer从xhtml生成pdf文件,你知道为什么这段代码总是出现x异常吗

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();
}

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

java.lang.NoSuchMethodError:com.lowagie.text.Rectangle.height(),那么这可能是库版本问题。因此,您正在使用的一个或多个JAR不兼容。您的类路径中可能有两个不兼容的库版本(即xhtmlrenderer库可能需要的lowagie库版本不是您正在使用的版本)。谢谢:)我有版本R8pre2。更改为R8后,它开始工作。(对不起我的英语)@CookieMonster:你能接受我的回答吗?这个问题可以被认为已经结束了?为什么我会有一种永远都不会的感觉;值得一试:)。