html4pdf vs iText

This comparison is unusual in that the deciding factor is often legal rather than technical. Teams rarely leave iText because it is not good enough.

The short answer

If you need deep PDF manipulation on the JVM and can accept AGPL or buy a licence, iText is the strongest tool available. If you only need HTML turned into a document, the licence question is one you can skip entirely.

What iText is

iText is a mature PDF library for Java and .NET covering creation, manipulation, signing, forms, redaction and PDF/A. Its pdfHTML add-on converts HTML and CSS to PDF. It is dual licensed: AGPL, which requires you to publish the source of anything that uses it over a network, or a commercial licence.

Side by side

 iTexthtml4pdf
ScopeThe whole PDF specificationHTML, URLs and templates in, PDF out
LicenceAGPL, or commercialPay per document, no licence terms on your code
HTML and CSSVia pdfHTML, its own implementationHeadless Chrome
JavaScript in the pageNot executedRuns before capture
Digital signaturesYes, thoroughlyNo
PDF/A and PDF/UAYesNo
Editing existing PDFsYesNo, generation only
Where it runsIn your JVMAn HTTPS call

Choose iText when

  • You need signing, redaction, PDF/A or form manipulation, not just generation.
  • Your product is open source, so AGPL costs you nothing.
  • You have bought a commercial licence already.
  • Everything must happen inside the JVM with no outbound call.

Choose html4pdf when

  • You only need HTML turned into a document, and the licence conversation is pure overhead.
  • Legal has asked what AGPL means for your closed source product.
  • Your markup is a modern web page that pdfHTML's own CSS engine does not reproduce.
  • You want the same approach from Java, Python and Node without three libraries.

See the code

The working example, in the language this decision is being made in.

iText: common questions

Is iText free for commercial use?

Only under AGPL, which generally requires publishing the source of the application that uses it, including over a network. Closed source products need a commercial licence. This is the usual reason teams look elsewhere.

What are the alternatives to iText in Java?

OpenPDF, a fork of the last LGPL version of iText, for manipulation. openhtmltopdf for XHTML with CSS 2.1. Apache PDFBox for low-level work. Or a rendering API when the input is a web page.

Does iText render modern CSS?

pdfHTML implements its own CSS support, which is good but is not a browser. Flexbox, grid and scripted content are where the gap shows.

Can I use both?

Commonly, yes: render the page with an API, then use a PDF library for signing or merging afterwards. They solve different problems.

Try it before you decide

New accounts get 10 free credits, no card. Send the HTML you already have and compare the output against whatever you are using now.

Get API key

Other comparisons