[英]PDF generated with Apache FOP is empty
我目前正在为公司项目开发模块,并且正在使用Apache FOP 2.3从xml生成pdf。
我在使用FOP时遇到问题,当我尝试使用我们的测试文件测试实现时,FOP生成几乎为空的pdf,它们的唯一内容是:
%PDF-1.4%клмн
并且我得到org.apache.fop.fo.ValidationException: "fo:table-row" is missing child elements. Required content model: (table-cell+) (No context info available)
org.apache.fop.fo.ValidationException: "fo:table-row" is missing child elements. Required content model: (table-cell+) (No context info available)
错误。 我尝试在fop.conf文件中将严格的验证器设置为false,但这对异常没有帮助。
这是我的pdf生成代码:
FopFactory fopFactory = FopFactory.newInstance(FOPCONFIGFILE);
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, destination);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new StreamSource(xslFile));
JDOMSource docEntreeJDOM = new JDOMSource(docJDOM);
org.w3c.dom.Document doc = transformJdomToDom(docJDOM);
Result result = new SAXResult(fop.getDefaultHandler());
transformer.transform(docEntreeJDOM, result);
该模块用于使用fop 0.20.5来工作。 但是,在更改为最新版本后,我遇到了这些问题。
我在xsl和示例文件上使用了Apache-FOP 2.3的命令行版本,以便从日志中获取更多信息(因为eclipse不会为我提供错误的内容或内容)。
从那以后,我已经更正了我的xsl文件,它们产生了正确的pdf输出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.