makesPDF
← Back to How to create a PDF

Python, Java and .NET libraries (ReportLab, iText, fpdf2, PDFBox, QuestPDF)

By Jason Galea · Part of the How to create a PDF benchmark

Takeaway: Server-side SDKs like ReportLab and iText are mature and self-contained, but ReportLab emits no tags, iText's PDF/UA mode is strict enough to throw on missing glyphs and link titles, and both dropped CJK and emoji out of the box.

Sample PDFSizePagesTaggedPDF/UA-1PDF/A-2aZürich / 東京 / 🚀Fig altTable tags
reportlab55 KB2nofail (12r / 251c)fail (10r / 285c)✓ ✗ ✗✗✗
itext-html2pdf50 KB2nofail (7r / 386c)fail (4r / 773c)✓ ✗ ✗✗✗
itext-pdfua1142 KB2yesPASSfail (4r / 773c)✓ ✗ ✗✓✓

1 iText's PDF/UA mode refused to write the unmodified reference document three times; this pass is for a copy with CJK and emoji removed and a title added to the link.

Checked with veraPDF 1.28.2 (r = failed rules, c = failed checks). Click any sample name to download the PDF, or test your own output in /validate (free, no sign-in) and inspect structure trees in /tags.

Before headless browsers took over server-side PDF generation, programmatic SDKs in Python, Java and .NET were the standard way to build invoices, statements and audit reports. They are still widely used when teams want everything running in-process inside an existing backend.

What we measured

We rebuilt the shared Quarterly Field Report in ReportLab 5.1.2 (Python) and iText 9.8.1 + pdfHTML 6.3.4 (Java).

ReportLab 5.1.2 (reportlab)

I spent about seven years maintaining a ReportLab PDF export pipeline in Python at SafetyCulture, so I have a soft spot for it. Once you get used to Platypus flowables, it is fast and predictable.

On modern standards and Unicode, though, the gaps show immediately. reportlab.pdf (55 KB, 2 pages):

  • Untagged with no alt text: failed PDF/UA-1 on 12 rules (251 checks) and PDF/A-2a on 10 rules (285 checks).
  • Dropped CJK and emoji: 東京 and 🚀 did not survive extraction (and left .notdef / ToUnicode failures), and standard Helvetica wasn't embedded.
  • Even "Page n of N" takes boilerplate: getting total page counts in ReportLab requires writing a two-pass custom Canvas subclass; our sample only prints "Page n".

ReportLab is also what ChatGPT-style Python code sandboxes reach for by default, which is why asking an AI assistant to "generate a PDF" usually gives you this exact untagged, Latin-only profile.

iText 9.8.1 + pdfHTML 6.3.4 (itext-html2pdf, itext-pdfua)

iText (now part of Apryse) is the heavyweight enterprise option for Java and .NET.

  • itext-html2pdf.pdf (50 KB, 2 pages): default HTML conversion is untagged (7 rules / 386 UA-1 checks, 4 rules / 773 A-2a checks) and dropped both CJK and emoji (iText's addDirectory didn't pick up the CJK font inside a .ttc collection). One size gotcha on our first try: letting pdfHTML's font provider pull in system fonts produced a 10 MB PDF until we constrained it.
  • itext-pdfua.pdf (142 KB, 2 pages): iText's PdfUADocument is the strictest standards writer in the entire 26-sample benchmark. Instead of quietly emitting a broken file, it validates while writing and throws an exception. On the unmodified reference report, it threw three times in a row:
    1. on the link annotation lacking alt text (fixed by adding a title attribute),
    2. on an unembedded Times-Roman fallback font, and
    3. on unmappable CJK and emoji glyphs.

Once we worked around all three (removing CJK/emoji and adding the link title), itext-pdfua.pdf passed PDF/UA-1 with full Table/THead/TBody/TR/TH/TD and Figure /Alt. It still failed PDF/A-2a (4 rules / 773 checks, mostly DeviceRGB and XMP PDF/A metadata) because PDF/A requires separate configuration.

That strictness is a double-edged sword: it guarantees you will not accidentally ship a non-conformant PDF/UA file, but your pipeline will throw at runtime if a customer enters a character your registered fonts don't cover.

Other libraries not run yet

  • fpdf2 (Python): lightweight and popular for straightforward Python scripts, but no PDF/UA tagging.
  • Apache PDFBox (Java): low-level drawing, parsing and manipulation (similar to pdf-lib in JS); not a layout engine.
  • QuestPDF (.NET): modern C# fluent layout library that has added PDF/UA support. Worth benchmarking once we add a .NET pass to the harness.

Licensing matters here

ReportLab's open-source edition is BSD-licensed. iText's community edition is AGPL-3.0, which means most commercial SaaS or enterprise teams need a paid commercial licence from Apryse. Check the licence before building a product on top of it.

Pros and cons

Pros

  • Mature, fast, self-contained inside your Python, Java or .NET service with no browser or external HTTP calls.
  • iText's PdfUADocument enforces PDF/UA rules at write time and supports deep PDF manipulation (digital signatures, redaction, form filling, PDF/X).

Cons

  • Verbose layout code (and manual font-fallback setup for CJK and emoji).
  • ReportLab and fpdf2 do not emit PDF/UA structure trees; iText's PDF/UA mode needs clean inputs and careful font wiring.
  • Commercial licensing cost and procurement overhead for iText.

When a server-side SDK is the right call

  • You need PDF manipulation beyond generation (digital signing, redaction, merging, filling existing third-party forms) or pre-press PDF/X. That is iText's home turf.
  • You run an on-prem or air-gapped JVM/.NET/Python backend with strict rules against external APIs.

If you just want clean, accessible PDFs from data or Markdown without maintaining layout code, font fallback or AGPL licences, compare Typst, WeasyPrint or makesPDF.