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 Rasterize PDF files in Java (Tutorial)

45 sec read

Convert PDF to Image

In this tutorial we show you how to rasterize a PDF file into an image in Java. You will need an external library to do this – this example uses our JPedal PDF library.

How to Rasterize a PDF file in Java

  1. Download a trial copy of JPedal and add it to your IDE.
  2. Create a File handle, InputStream or URL pointing to the PDF file
  3. Include a password if file password protected
  4. Open the PDF file
  5. Iterate over the pages
  6. Close the PDF file

and the Java code to rasterize PDF…

What is rasterizing a PDF file?

When you rasterize a PDF file, you convert the pages of the document into raster image files. Rasterizing the file stops editing and removes the need for a PDF viewer to show the pages. This makes it simpler to view. The disadvantage of a raster based image is that you lose all the features of the PDF file and Viewer, and have all the limitations of a bitmap display.



Why do developers choose JPedal over alternatives?

  1. Actively developed commercial library with full support and no third party dependencies.
  2. Simple licensing options and source code access for OEM users.
  3. Process PDF files up to 3x faster than alternative Java PDF libraries.

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

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.