从 Java 创建 PDF 并在网页中显示它
目前我正在使用 FOP 从 java 代码和 xslt 文档生成 pdf。 FOP 生成一个 PDF 文件,并显示(嵌入)到网页中。 这些文档的长度可以从一页到几千页不等,并且生成它们可能需要一些时间。
有没有更好的工具可以做到这一点? FOP 是开源和自由世界中的最佳选择吗?
Currently I am using FOP to generate a pdf from java code and an xslt document. The FOP spits out a PDF file that is displayed (embeded) into a webpage. The documents can range between one and several thousand pages long, and it can take some time to generate them.
Is there a better tool that and do this? Is FOP the best option in the opensource and free world?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我们使用 iText。
这是一篇博客文章 Apache FOP 与 iText 的比较< /a>.
根据您的使用情况(从 java 代码和 xslt 文档生成 pdf)来看,FOP 似乎是您更好的选择。
编辑:此论坛帖子关于 FOP 与 IText 包括以下内容:
We use iText.
Here is a blog entry Comparing Apache FOP with iText.
Judging by your usage (generate a pdf from java code and an xslt document) it seems like FOP is the better choice for you.
EDIT: This forum post about FOP Vs IText includes the following:
这个答案对你来说已经太晚了,但是如果它可以帮助其他搜索者,Docmosis 可以以相当大的速度生成文档率,并且可以将高负载分散到多台机器上。 它使用 OpenOffice 作为底层格式转换引擎,通过 Docmosis Java API 添加文档填充和操作工具。
几千页文档将花费大多数系统一段时间,但是如果系统(或您的代码)允许您并行和分配工作量,那么至少平均文档速率会很高,即使单个文档时间可能会很长。重要的。
JODReports 是另一个类似的选项。
This answer is too late for you, but in case it helps other searchers, Docmosis can generate documents at a fairly hefty rate, and can spread a high load across multiple machines. It uses OpenOffice as the underlying format conversion engine, adding document population and manipulation facilities via the Docmosis Java API.
Several thousand page documents are going to take most systems a while, but if the system (or your code) allows you to parallelise and distribute the effort, then at least the average document rate can be high, even if the individual document time may be significant.
JODReports is another similar option.
您可以使用 OpenOffice.org,作为服务器运行并远程命令它进行文档转换。
除了 HTML 到 PDF 之外,还可以进行其他转换:
文档--> pdf、html、txt、rtf
xls--> pdf、html、csv
PPT--> pdf、swf
代码示例:
import officetools.OfficeFile;
...
FileInputStream fis = new FileInputStream(new File("c:/test.html"));
FileOutputStream fos = new FileOutputStream(new File("c:/test.pdf"));
// 假设 OpenOffice.org 在 localhost、端口 8100 上运行
OfficeFile f = new OfficeFile(fis,"localhost","8100", true);
f.convert(fos,"pdf");
从:使用 PHP、Java 或 ASP 将 HTML 转换为 PDF:
dancrintea.ro/html-to-pdf/
You can use OpenOffice.org, running as a server and command it remotely for document convertion.
Besides HTML to PDF, there are also possible other convertions:
doc --> pdf, html, txt, rtf
xls --> pdf, html, csv
ppt --> pdf, swf
Code example:
import officetools.OfficeFile;
...
FileInputStream fis = new FileInputStream(new File("c:/test.html"));
FileOutputStream fos = new FileOutputStream(new File("c:/test.pdf"));
// suppose OpenOffice.org runs on localhost, port 8100
OfficeFile f = new OfficeFile(fis,"localhost","8100", true);
f.convert(fos,"pdf");
From: HTML to PDF with PHP, Java or ASP:
dancrintea.ro/html-to-pdf/
Adobe ColdFusion 具有最佳的内置 PDF 支持。
Adobe ColdFusion has the best built-in PDF support.