将这些用于 PDF 生成的产品与 Java 中给出的要求进行比较:iText、Apache PDFBox 或 FOP?

发布于 2024-11-19 00:34:33 字数 1539 浏览 3 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(7

对不⑦ 2024-11-26 00:34:35

我有点偏见(提交者),但我建议使用 iText。

根据预定义模板生成pdf文档(我可以使用pdf表单或xsl-fo)

PDF 表单:检查

能够填充文本数据

PDF 表格,检查。您还可以执行编程布局。

能够填充图形数据(生成条形码)

检查。给定一个已知位置(可能是“该特定注释的位置”),iText 将为您绘制一个给定符号系统和值的条形码。您可以从此处列出的常量推断出支持的符号系统列表。

对于此类事情,我使用具有“仅图标”外观的按钮字段。 “图标”是一些任意的 PDF 绘图指令或图像。 iText 的条形码内容将创建一个 PdfTemplate,您可以将其填充到按钮中而不用太麻烦。

能够在生产环境中更改 pdf 模板而无需修补(重新编译)

如果您的所有布局都已烘焙到 PDF 模板中,并且您的“条形码位于此处”信息未硬编码到源中,那么您就很出色。

生成要保存在数据库中(作为 blob)和/或打印的 pdf 文件

PDF 是 PDF 是 PDF。哎呀,只要您做一些额外的工作,您就可以使用 iText 来构建 PDF/A 文件。 “A”代表存档。

开源/免费

开源:是的。 v2.1.7 是使用 MPL 的最后一个版本。从 5.x 开始,所有 iText 版本都在 AGPL 下。是的,iText 从 2.1.7 跳到了 5.0,以便同步 iText 和 iTextSharp 之间的版本编号。

“little f”并不完全免费,但 2.1.7 版本并不难获得。 OTOH,它是孤儿软件,没有维护。做一个知情的消费者。

I'm a bit biased (committer), but I suggest iText.

generating pdf documents based on predefined template (I can use either pdf forms or xsl-fo)

PDF forms: Check

being able to fill textual data

PDF Forms, check. You can also perform programmatic layout.

being able to fill graphical data (generated bar codes)

Check. Given a known location (which could be "the location of this particular annotation"), iText will draw a barcode for you given a symbology and value. You can deduce a list of supported symbologies from the constants listed here.

For this sort of thing, I use Button fields with an "Icon Only" appearance. The "icon" is some arbitrary PDF drawing instructions, or an image. iText's barcode stuff will create a PdfTemplate you can stuff into the button without too much trouble.

being able to alter pdf template in production environment without patching (recompiling)

If all your layout is baked into the PDF template, and your "barcode goes here" info isn't hard coded into the source, then you're golden.

generating pdf file to be saved in the database (as blob) and/or printed

A PDF is a PDF is a PDF. Heck, with some extra work on your part, you can use iText to build PDF/A files. "A" is for Archive.

open source/free

Open Source: Yes. v2.1.7 was the last version to use the MPL. Since 5.x, all iText releases have been under the AGPL. Yes, iText skipped from 2.1.7 to 5.0, in order to synchronize the version numbering between iText and iTextSharp.

Not exactly "little f" free, but the 2.1.7 version isn't that hard to come by. OTOH, it's orphan-ware, unmaintained. Be an informed consumer.

她比我温柔 2024-11-26 00:34:35

这也取决于您想要如何创建 PDF。 FOP 基于 XML 工作,IText 允许您通过 Java 以编程方式创建。

It depends how exactly you want to create the PDF as well. FOP works from XML, IText lets you create programmatically from Java.

梦屿孤独相伴 2024-11-26 00:34:35

另一个对飞碟的竖起大拇指。如果您熟悉 html 和 css,它效果很好并且很容易使用。

没有真正记录的是如何访问 iTexts 内置条形码功能。然而,这可以很容易地实现。我在这里发布了一个简短的教程: http ://andreas.haufler.info/2012/12/generate-barcodes-in-pdfs-with-flying.html

Another thumbs up for flying-saucer. It works quite well and is easy to use if you're familiar with html and css.

What isn't really documented is how to access iTexts built-in barcode functionality. However this can be easily accomplished. I've put up a short tutorial here: http://andreas.haufler.info/2012/12/generating-barcodes-in-pdfs-with-flying.html

雨后咖啡店 2024-11-26 00:34:35

没有人在谈论BFO(Big Faceless),尽管它是商业的

nobody is talking about BFO(Big faceless) though it's commercial

拧巴小姐 2024-11-26 00:34:34
  1. i文本;如今 iText 是一个商业库,最新版本不再免费(旧版本的分支仍受 MIT 许可:OpenPDF)
  2. FOP;我和 FOP 一起工作了很多。它是相当资源密集型的(Java > XML > XSLT > PDF),复杂的 PDF 成为一场噩梦(可能会导致 XSLT 具有 20k+ LoC)
  3. PDFBox;它似乎是最好的选择,尽管我没有在大型项目中使用过它,
  4. 但还没有检查 Flying Saucer

总而言之,我会尝试一下 PDFBox。根据您的条形码要求,您可能需要将条形码(字体)内联到 PDF 中或将字体分发给您的客户 - 解决这些问题。

  1. iText; nowadays iText is a commercial library, the latest version is not for free anymore (a fork of an older version remains under MIT license: OpenPDF)
  2. FOP; I worked a lot with FOP. It's fairly resource intensive (Java > XML > XSLT > PDF) and complex PDFs become a nightmare ( may result in XSLTs with 20k+ LoC)
  3. PDFBox; it seems to be the best alternative although I did not work with it in large projects
  4. Did not check Flying Saucer yet

To conclude, I'd give PDFBox a try. Depending on your bar code requirements you may need to inline your barcode (font) into the PDF or distribute the font to your clients - take care of those issues.

战皆罪 2024-11-26 00:34:34

我用 Flying Saucer 完成了一个项目 http://code.google.com/p/flying -saucer/ 基于 iText。它是免费的,易于使用,对 CSS 有很好的支持,并且有很好的开源功能。

I've done a project with Flying Saucer http://code.google.com/p/flying-saucer/ which is based on iText. It's free, easy to use, has great support for CSS, and has nice open source.

烟沫凡尘 2024-11-26 00:34:34

我认为 iText 和 Apahce FOp 都可以满足您的标准,但这里您还有一些额外的标准:

  • 许可:FOP 基于 Apache 许可证,因此对于商业用途也“友好”
  • 灵活性:像 iText 这样的低级 API 比高级 FOP
  • 可视化工具:这里有一个 FOP 设计器
  • 编程模型:iText基于编程API,而FOP需要XSLFO模板,编程量较少。
  • 专有与标准。 Apache FOP 基于标准,因此独立于供应商,而 iText 是专有 API
  • 性能:据说 FOP 的计算强度更大。当然,这取决于您的目标 PDF 文件是什么。对于使用 FOP 的我来说这从来都不是问题。

我不会使用 PDFBox,它对于读取和修改现有 PDF 文件很有用,但使用 PDFBox 从头开始​​创建文件可能需要大量工作。

I think your criteria can be met with both iText and Apahce FOp but here you have some additional criteria:

  • licensing: FOP is based on Apache license and therefore "friendly" also for commercial use
  • flexbility: a low level API like iText is more flexible than high level FOP
  • Visual tools: there is one designer for FOP here.
  • Programing Model: iText is based on programming API while FOP requires a XSLFO template and less programming.
  • Proprietary vs standard. Apache FOP is based on a standard and therefore vendor independent, while iText is a proprietaRy API
  • Performace: It is said FOP is more computing intensive. it depends of course of what your target PDF files are. It was a never issue for me using FOP.

I would not use PDFBox, it is good for reading and modifying an existing PDF file but createing a file from scratch using PDFBox can be a lot of work.

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