Mark Stephens Mark founded the company and has worked with Java and PDF since 1997. The original creator of the core code, he is also a NetBeans enthusiast who enjoys speaking at conferences and reading. He holds an Athletics Blue and an MA in Mediaeval History from St. Andrews University.

How to work with PDF files in Java

3 min read

A Java PDF library is a third-party JAR that parses, renders, or generates PDF files from Java code. The JDK has no native PDF support: javax.print can send bytes to a printer, but nothing in the standard library can read a PDF’s object graph, decode its content streams, or draw a page. Every PDF task in Java goes through a library.

Which one you need depends on the task. Creating documents, editing raw objects, and rendering pages are three different problems, and no single library is the best answer to all three. Budget, license terms, and support expectations narrow it further.

Java PDF libraries compared

LibraryLicensePrimary use
Apache FOPApache 2.0Generating PDF from XSL-FO
Apache PDFBoxApache 2.0Reading, extraction, rendering, basic creation
DatalogicsCommercialAdobe PDF Library access from Java
iTextAGPL v3 or commercialCreation and low-level object editing
JPedalCommercialRendering, extraction, viewing, printing

What do you want to do with the PDF file?

All of the libraries below expose a Java PDF API. Find the task, then the tool.

What can you do with JPedal?

JPedal is our commercial Java PDF library. It requires Java 17 or later and provides a Java PDF API allowing you to:

  • Access and edit form and annotation data
  • Add a PDF viewer to Java applications
  • Convert PDF documents to images (including HEIC)
  • Extract images, text, and metadata
  • Inspect a PDF file
  • Print PDF files
  • Search text

You can also use our extensive PDF Library guide to help you choose the right library for you. Alternatively, if you choose build your solution in-house, our build vs buy guide can help you figure out development timelines and implication for your specific workflows.

FAQ

Does the JDK include a PDF library?

No. javax.print and java.awt.print can send a rendered image to a printer, and javax.imageio handles raster formats, but nothing in the standard library parses PDF syntax or decodes content streams. You need a third-party JAR for any PDF work.

Can I use iText in a closed-source commercial product for free?

No. The free distribution of iText is AGPL v3, which requires you to release the source of any application that uses it, including applications only reached over a network. Shipping closed-source software means buying a commercial license. Apache PDFBox and Apache FOP are Apache 2.0 and carry no such requirement.

Why do two libraries produce different output from the same PDF?

PDF is a description of drawing operations, not a fixed rendering. Differences in font substitution when an embedded font is missing, color space and ICC profile handling, blend mode support, and shading pattern interpolation all produce visibly different pages from identical input. This is why rendering fidelity is worth testing against your own corpus rather than trusting a feature matrix.



The JPedal PDF library allows you to solve these problems in Java


Mark Stephens Mark founded the company and has worked with Java and PDF since 1997. The original creator of the core code, he is also a NetBeans enthusiast who enjoys speaking at conferences and reading. He holds an Athletics Blue and an MA in Mediaeval History from St. Andrews University.