pdfRender
pdfRender is an iText 7 Core add-on that allows you to generate images from PDFs, effectively converting a PDF to an image so you can create PDF file renders for your displaying needs, or to ensure compatibility with archival and legacy workflow requirements.
With pdfRender you can get exact copies of PDF pages which can be viewed on any device, without requiring a PDF viewer.
How it works
pdfRender enables you to easily display (render) any PDF as an image.
The code below takes a PDF file as input and produces a visually equivalent set of JPEG images.
public void render() throws IOException {
final RenderingProperties properties = new RenderingProperties();
properties.setImageType(PdfRenderImageType.JPEG);
PdfToImageRenderer.renderPdf(new File(ORIG), new File("out/"), properties);
}
Bear in mind that the output image size will match the original PDF. So, if you want to render a PDF to a specific image size you should scale the PDF first before rendering it as an image, e.g. properties.setPageScaling((float) 2);
will scale the PDF by 200%.
NOTE: pdfRender is now available in two versions; a Java version, and also a CLI (Command Line Interface) version which you can call from any language.
pdfRender CLI includes a number of command-line switches which you can use. Note that --license
is required and is used to specify the location of your pdfRender license file (our 30-day free trial includes a trial license file you can use).
Switch | Description |
---|---|
--license <license> | Path to JSON license file [required] |
--out-dir <out-dir> | Output directory |
--out-path-pattern <out-path-pattern> | Output file name pattern |
--password <password> | PDF password [optional] |
--pdf <pdf> | Path to input PDF file |
--scaling <scaling> | Page scaling [optional] |
--type <type> | Output image type [optional]. JPEG is used as default |
Usage examples
To convert a PDF named "rendertest.PDF" to a JPG you would use the following command:
pdfrender --license <path to license file> --pdf rendertest.pdf --out-path-pattern rendertest
This converts a PDF named "rendertest.PDF" to a PNG scaled to 50% of the original size:
pdfrender --license <path to license file> --pdf rendertest.pdf --out-path-pattern rendertest --scaling 0.5 --type png
Core capabilities of iText 7 pdfRender
With iText pdfRender you can render PDFs into images. The add-on enables you to create small thumbnails, or pixel-perfect high-resolution images of the pages.
Rendering images of PDFs can be achieved with only a couple of lines of code, as shown in our examples. You can choose your desired output from a range of supported image formats, whether you need high-quality renders or just a quick thumbnail image.
Supported Formats: BMP, HEIC, JPEG, JPEG 2000, PNG, TIFF, WEBP
Use pdfRender to display PDF files in various image file formats, simple or complex. For instance, you can render a single page of a PDF to an image, or multiple pages to multiple images.
Pixel-perfect conversion
With iText pdfRender, you can rely on the best possible image output quality with control over the image type, page scaling and range.
Mobile-friendly PDF viewing
With pdfRender you can display a PDF on a mobile device (or any platform) without needing to install a PDF reader.
Leverages pdfXFA to render XFA as an image
By using the power of pdfXFA, you can even render your XFA forms into images.
Why use iText 7 pdfRender?
pdfRender is one of the fastest and most convenient ways to render PDF as images.
Create thumbnails of book covers for instance, or quickly display bank statements, legal documents, contracts, templates and much more. You end up with lightweight, pixel-perfect images of your PDF documents.
You can use those images instead of the PDF documents themselves to display your documents in applications, or to save for archiving purposes.
Images can easily be viewed on mobile devices, or in any environment. No need to install a PDF viewer, or worry about if it will display your PDF correctly.
Ease of use
pdfRender requires simple set-up: enabling fully automated rendering of PDF as images.
3.5x faster than Apache pdfBox
comparable to GhostScript (native)
Generate PDF file previews and thumbnails
Preview PDF documents in file management applications, document management systems etc.
Easily display digital signatures
pdfRender allows you to display a digitally signed PDF as easily as displaying an image.
Resources
Here you will find the resources needed to install and use pdfRender.