从 Java 创建 PDF 并在网页中显示它

发布于 2024-07-10 10:40:20 字数 162 浏览 5 评论 0原文

目前我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

黒涩兲箜 2024-07-17 10:40:20

我们使用 iText

这是一篇博客文章 Apache FOP 与 iText 的比较< /a>.

根据您的使用情况(从 java 代码和 xslt 文档生成 pdf)来看,FOP 似乎是您更好的选择。

编辑:此论坛帖子关于 FOP 与 IText 包括以下内容:

就 PDF 而言,iText 比 FOP 功能更丰富:您可以添加注释、创建 AcroForms、对 PDF 文档进行数字签名。 如果您需要生成包含数千或万页的 PDF 文档,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:

iText is more feature rich than FOP as far as PDF is concerned: you can add annotations, create AcroForms, digitally sign a PDF document. Also iText is the only solution if you need to generate PDF documents containing thousands or ten thousands of pages.

吾家有女初长成 2024-07-17 10:40:20

这个答案对你来说已经太晚了,但是如果它可以帮助其他搜索者,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.

ぇ气 2024-07-17 10:40:20

您可以使用 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/

长安忆 2024-07-17 10:40:20

Adobe ColdFusion 具有最佳的内置 PDF 支持

Adobe ColdFusion has the best built-in PDF support.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文