是否有 xsl:fo 报告或 xsl:fo 模拟之类的东西?
我试图确定我的 xsl:fo 生成的 PDF 文件是否会超过一页,而不实际生成输出。我们在服务器上使用 Apache-FOP 0.95,并且在传递到 XSL-FO 模板之前使用 PHP DOMDocument 类生成 XML 数据。
我的问题:
是否有 PHP 库可以模拟 xsl:fo 输出并向我发送可以在我的应用程序中使用的报告?
或者,是否有一种方法可以让 Apache FOP 本身(或同级 Java 应用程序)发送报告而不实际生成文件?我一直在阅读 FOP 文档,除了一些我无法完全理解的事情之外,我还无法找到从 FOP 内部做到这一点的方法。
I am trying to determine if MY xsl:fo generated PDF file will exceed one page or not, without actually generating the output. We use Apache-FOP 0.95 on our server, and the XML data is being generated using a PHP DOMDocument class before being passed onto an XSL-FO template.
My question:
Are there PHP libraries out there that can simulate xsl:fo output and send me reports that I can use in my application?
Alternatively, is there a way for the Apache FOP itself (or sibling Java app) that sends reports without actually generating a file? I have been reading the FOP documentation, and aside from some things I can not fully understand, I have not been able to find a way to do that from within FOP.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果不通过布局引擎实际运行文档,就不可能“模拟”文档。此外,不同的 FO 处理器可能会产生略有不同的输出,因此您不能依赖一个处理器的结果来猜测另一个处理器的页数。
您可以使用 Apache FOP 0.95 生成所谓的 Area Tree XML(或中间格式),例如,它基本上将布局结果输出为 XML 文件而不是 PDF。然后可以使用 XPath(或 XSLT)检查该 XML 文件以确定页数。 XML 格式没有正式描述,但您很快就会明白如何确定页数。因此,通过在命令行上使用“-at application/pdfsimulation.xml”而不是“-pdfoutput.pdf”,您可以生成该 XML 格式。当然,在这种情况下需要完成生成最终文档所需的大部分处理,因此重新运行整个文档进行 PDF 生成将花费相当长的时间。好消息是,您可以再次使用 AT XML 作为输入来生成最终的 PDF,因此不必再次运行布局阶段(请参阅文档中的“-atin”参数)。
当然,另一种可能性是仅使用 PDF 工具来确定最终文档的页数。
华泰
Without actually running the document through the layout engine there's no possibility to "simulate" the document. Also, different FO processors may produce slightly different output, so you can't rely on the result from one to guess on the number of pages of another.
What you can do with Apache FOP 0.95 is generate the so-called Area Tree XML (or intermediate format) which basically outputs the layout result as an XML file instead of a PDF, for example. That XML file could then be inspected using XPath (or XSLT) to determine the number of pages. The XML format is not formally described, but you'll quickly see how you can determine the number of pages. So, by using "-at application/pdf simulation.xml" instead of "-pdf output.pdf" on the command-line, you can produce that XML format. Of course, most of the processing required to produce the final document needs to be done in this case, so re-running the whole document again for PDF production will cost quite some time. The good news is that you can use the AT XML as input again to produce the final PDF so the layout stage doesn't have to be run again (see "-atin" parameter in the documentation).
Another possibility is, of course, to just use a PDF tool to determine the number of pages of the final document.
HTH