Java PDF Libraries

Looking today for a few OSS options for generating PDFs from Java. Here’s a quick summary of what I’ve found:

  • Apache FOP – generates PDFs from a library-specific XML document. You can use XSLT to translate your own XML into the library-specific XML.
  • iText – generates PDFs using API calls.
  • xhtmlrenderer (AKA Flying Saucer Project) – generates PDFs from HTML documents. You can use your regular templating engine to create the HTML, or even put the renderer in a servlet filter in order to PDFify JSP output. As a result, maintenance is easier than with the other frameworks, because you’re maintaining template files of the same kind as your webapp. HTML is going to be less flexible than native PDF commands, but there is a workaround for repeating table headers and footers on each page, for example.

A well-known library I don’t recommend is pd4ml – it also generates PDFs from HTML documents, but, if memory serves me correctly, it isn’t as feature rich as xhtmlrenderer, and it’s also commercial (non-free) software.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: