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

时间:2022-12-08 21:11:08

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.

目前我正在使用FOP从java代码和xslt文档生成pdf。 FOP吐出一个PDF文件,显示(嵌入)到网页中。文档的长度可以在一到几千页之间,生成它们可能需要一些时间。

Is there a better tool that and do this? Is FOP the best option in the opensource and free world?

有没有更好的工具,并做到这一点? FOP是开源和*世界的最佳选择吗?

4 个解决方案

#1


1  

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.

这个答案对你来说太晚了,但是如果它能帮助其他搜索者,Docmosis可以以相当高的速度生成文档,并且可以在多台机器上传播高负载。它使用OpenOffice作为底层格式转换引擎,通过Docmosis Java API添加文档填充和操作工具。几千页的文档将占用大多数系统一段时间,但如果系统(或您的代码)允许您并行化并分配工作量,那么即使单个文档时间可能很长,至少平均文档速率也可能很高。重大。

JODReports is another similar option.

JODReports是另一个类似的选择。

#2


4  

We use iText.

我们使用iText。

Here is a blog entry Comparing Apache FOP with iText.

这是一篇博客文章比较Apache FOP和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.

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

EDIT: This forum post about FOP Vs IText includes the following:

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

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.

就PDF而言,iText比FOP更丰富:您可以添加注释,创建AcroForms,对PDF文档进行数字签名。如果您需要生成包含数千或数千页的PDF文档,iText也是唯一的解决方案。

#3


1  

You can use OpenOffice.org, running as a server and command it remotely for document convertion.

您可以使用OpenOffice.org作为服务器运行并远程命令进行文档转换。

Besides HTML to PDF, there are also possible other convertions: doc --> pdf, html, txt, rtf xls --> pdf, html, csv ppt --> pdf, swf

除了HTML到PDF,还有其他转换: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"));

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

//假设OpenOffice.org在localhost,端口8100上运行

OfficeFile f = new OfficeFile(fis,"localhost","8100", true); f.convert(fos,"pdf");

OfficeFile f =新的OfficeFile(fis,“localhost”,“8100”,true); f.convert(FOS, “PDF”);

From: HTML to PDF with PHP, Java or ASP: dancrintea.ro/html-to-pdf/

从:使用PHP,Java或ASP从HTML到PDF:dancrintea.ro/html-to-pdf/

#4


0  

Adobe ColdFusion has the best built-in PDF support.

Adobe ColdFusion具有最好的内置PDF支持。

#1


1  

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.

这个答案对你来说太晚了,但是如果它能帮助其他搜索者,Docmosis可以以相当高的速度生成文档,并且可以在多台机器上传播高负载。它使用OpenOffice作为底层格式转换引擎,通过Docmosis Java API添加文档填充和操作工具。几千页的文档将占用大多数系统一段时间,但如果系统(或您的代码)允许您并行化并分配工作量,那么即使单个文档时间可能很长,至少平均文档速率也可能很高。重大。

JODReports is another similar option.

JODReports是另一个类似的选择。

#2


4  

We use iText.

我们使用iText。

Here is a blog entry Comparing Apache FOP with iText.

这是一篇博客文章比较Apache FOP和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.

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

EDIT: This forum post about FOP Vs IText includes the following:

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

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.

就PDF而言,iText比FOP更丰富:您可以添加注释,创建AcroForms,对PDF文档进行数字签名。如果您需要生成包含数千或数千页的PDF文档,iText也是唯一的解决方案。

#3


1  

You can use OpenOffice.org, running as a server and command it remotely for document convertion.

您可以使用OpenOffice.org作为服务器运行并远程命令进行文档转换。

Besides HTML to PDF, there are also possible other convertions: doc --> pdf, html, txt, rtf xls --> pdf, html, csv ppt --> pdf, swf

除了HTML到PDF,还有其他转换: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"));

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

//假设OpenOffice.org在localhost,端口8100上运行

OfficeFile f = new OfficeFile(fis,"localhost","8100", true); f.convert(fos,"pdf");

OfficeFile f =新的OfficeFile(fis,“localhost”,“8100”,true); f.convert(FOS, “PDF”);

From: HTML to PDF with PHP, Java or ASP: dancrintea.ro/html-to-pdf/

从:使用PHP,Java或ASP从HTML到PDF:dancrintea.ro/html-to-pdf/

#4


0  

Adobe ColdFusion has the best built-in PDF support.

Adobe ColdFusion具有最好的内置PDF支持。