Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

How to read PDF files in Java

1 min read

To read PDF files in Java, you will need a Java library to help you. PDF files are not handled natively by Java, and decoding the raw data in a PDF file is very complex. The contents of the PDF generally has to be parsed to extract anything meaningful from it.

The good news is that Java has a wide range of commercial and Open Source libraries available to choose from. Which is right for you will depend on what you want to do, along with your budget, support needs, speed requirements, etc.

What do you want to do with the PDF file?

Which library you use is going to depend on what exactly you want to do.

  • Do you want to read the raw PDF Objects and edit them, you will need a tool such as iText.
  • If you are creating PDF documents iText or FOP are worth investigating.
  • If you want to access the Adobe libraries from Java, Datalogics offers some solutions for this.
  • If you are trying to debug a broken PDF to understand what the issues are, you will need a PDF inspector to view the PDF objects and tree (personally I use a mixture of Rups and our own Inspector in JPedal). There are lots of Open Source and Commercial tools which can do this. Many people still use a text editor to look at the raw PDF structure.
  • If you want to print, extract content or rasterize the PDF pages as images, you should consider PdfBox, JPedal or one of the other commercial Java libraries out there.

What can you do with JPedal?

JPedal is our commercial PDF library. It allows you to:-

  1. Convert PDF documents to images (including Heic)
  2. Extract images, text and Metadata.
  3. Search text.
  4. Add a PDF Viewer to Java applications.
  5. Print PDF files
  6. Access and edit Form and Annotation data.
  7. Inspect a PDF file


Do you need to solve any of these problems?

Display PDF documents in a Web app
Use PDF Forms in a web browser
Convert PDF Documents to an image
Work with PDF Documents in Java

Are you a Developer working with PDF files?

Learn more about PDF file format
Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

Leave a Reply

Your email address will not be published. Required fields are marked *

IDRsolutions Ltd 2022. All rights reserved.