Convert PDF to Image in Java
JPedal converts PDF pages to raster images in pure Java. Output can be written directly to AVIF, BMP, GIF, HEIC, JPEG, JPEG2000, PNG, TIFF, or WEBP, or returned as a Java BufferedImage for in-memory processing.
Requirements
| Requirement | Value |
|---|---|
| Minimum Java version | Java 17 |
| Legacy Java support | Java 8 build from August 2024 available for projects that cannot upgrade |
| Third-party dependencies | None |
See Which Java versions does JPedal support? for full version details.
Generate thumbnails
All conversion methods accept either a float scaling value or a new int[] {width, height} array to constrain output dimensions. The fit-to-size option preserves aspect ratio.
Convert a PDF page to a BufferedImage
Use the BufferedImage path when you need in-memory access to page data: for example, to apply image processing before writing, to stream output without touching disk, or to feed pages into a pipeline that consumes BufferedImage objects directly. No temporary files are created.
Convert a PDF page to an image file
Supported formats:
Convert PDF to AVIF
Convert PDF to BMP
Convert PDF to GIF
Convert PDF to HEIC
Convert PDF to JPG
Convert PDF to JPEG2000
Convert PDF to PNG
Convert PDF to TIFF
Convert PDF to WEBP
Frequently Asked Questions
What image formats can JPedal convert PDF files to?
JPedal supports conversion to AVIF, BMP, GIF, HEIC, JPEG, JPEG2000, PNG, TIFF, and WEBP, as well as to a Java BufferedImage object for in-memory processing.
What is the default output resolution and how do I change it?
The default scaling of 1.33f matches Acrobat’s 100% view. To change the output resolution, pass a different float value to setPageScaling(). For example, 2.0f doubles the output dimensions. For higher-resolution output with additional control, use the ConvertPagesToHiResImages class.
How do I convert a single page instead of the whole PDF?
Use setPageRange() with a PageRanges value. For example, convert.setPageRange(new PageRanges("3")) converts only page 3. Ranges follow the SetOfIntegerSyntax format: "1-5,8,10" converts pages 1 through 5, plus pages 8 and 10.
Can JPedal convert password-protected PDF files?
Yes. Call convert.setPassword("yourPassword") before openPDFFile().
How do I generate thumbnails from a PDF?
All conversion methods accept either a float scaling value or a new int[] {width, height} array to constrain output dimensions. The fit-to-size option preserves aspect ratio: the output will be at most the specified width or height, whichever dimension is reached first.
What is the difference between ConvertPagesToImages and ConvertPagesToHiResImages?
ConvertPagesToImages covers the most common conversion use cases. ConvertPagesToHiResImages provides additional options for upscaling and fine-grained output control via JPedalSettings. Use it when output quality at large dimensions is critical.
Can I convert PDFs to images without writing Java code?
Yes. JPedal includes a command-line interface: java -jar jpedal.jar --convert "inputFile" "outputDir" jpg. This also allows invocation from any language that supports child processes, including Python, Node.js, C#, and shell scripts.
Is there sample code available for PDF to image conversion in Java?
Yes. A working example project is available on GitHub at github.com/idrsolutions/pdf-to-image.
Does JPedal require any third-party libraries for PDF to image conversion?
No. JPedal is a 100% Java solution with no third-party dependencies. There are no native binaries, no ImageMagick, and no Ghostscript required.
What Java version is required?
JPedal requires Java 17 as a minimum. A separate Java 8 build from August 2024 is available for projects that cannot upgrade. See Which Java versions does JPedal support?