Compare these products for PDF generation with Java given requirements inside: iText, Apache PDFBox or FOP?

topchef picture topchef · Jul 8, 2011 · Viewed 61.4k times · Source

There were questions on that but not recently and technology must have gone ahead since then.

Requirements:

  • generating pdf documents based on predefined template (I can use either pdf forms or xsl-fo)
  • being able to fill textual data
  • being able to fill graphical data (generated bar codes)
  • being able to alter pdf template in production environment without patching (recompiling)
  • generating pdf file to be saved in the database (as blob) and/or printed
  • open source/free

The options assumed are iText, PDFBox, FOP, anything else? What are recommendations based on the requirements above?

Answer

home picture home · Jul 8, 2011
  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.