New product release: Convert PDF to images with iText pdfRender

Introducing a new iText 7 add-on, pdfRender, which allows you to render PDFs as images. Powered by IDRsolutions, pdfRender integrates with iText 7 to enable the display of PDF content as easily as displaying an image.

pdfRender: display PDFs as images

It’s been only three weeks since the new year has kicked in, and we’re already excited to share some great news with you! A new add-on has been added to the iText PDF library: from today, with iText pdfRender, you can convert (or to be more exact, render) PDFs to images with iText.

The iText developers are constantly working hard to further enhance and enrich our document technology. Despite the many benefits of the PDF format, there are various occasions when you will want to use an image of the PDF document rather than the document itself. For example, here are a few use cases we’ve encountered:

  • Generating PDF file previews and thumbnails: we often see this in app development when users want to preview PDF documents in file management applications, document management systems, digital signing applications and many more.
  • Simple viewing of PDF content: mobile devices or web browsers might not be able to handle the complexity of PDF files because of transparency, color calibration etc. Alternatively, some users need to flatten out complexity into a rendered format.
  • Compatibility with archival and legacy workflow requirements: which may require raster image formats such as TIFF.

In order to help our users and clients who have these use cases, we have added pdfRender to our portfolio. pdfRender is an iText 7 Core add-on that allows you to generate images from PDFs, so that you can create PDF file renders for your displaying needs, or to ensure compatibility with archival and legacy workflow requirements. For the development of this new add-on, we worked together with IDRsolutions, a well-known technology provider of Java SDKs.

We’re excited about this new addition, as, in line with our striving for high quality technology, pdfRender is one of the fastest and most convenient ways to render PDF as images in the market today.

The simple set-up makes it very easy to use and it also exceeds performance of similar available tools out there. It is for instance 3.5x faster than Apache pdfBox. That comes in handy in enterprise usage when thousands and thousands of PDF to image conversions need to happen.

As it is integrated into iText itself, you can do more than just convert a PDF to an image: by using pdfXFA you can also render your XFA forms as images as well.

Back to pdfRender itself: the code enables you to create small thumbnails or high-resolution images of the pages of your PDF files. A substantial advantage is that we support a wide range of formats: BMP, JPEG, JPEG2000, PNG, and TIFF. By giving you control of options such as the image type, page scaling and range, you can ensure that the quality of the rendering will, we dare to say, be pixel-perfect.

More complex use cases are also possible. For instance, you can render a single page of a PDF to an image, or multiple pages to multiple images.

pdfRender Examples

To demonstrate the new functionality, here's a couple of quick examples:

This first one takes a PDF and generates images using the default options, which is JPEG files named "image1.jpg", "image2.jpg" etc. "ORIG" is the input PDF file path and "out/" is the output directory.

public void render() throws IOException {
    PdfToImageRenderer.renderPdf(new File(ORIG), new File("out/"));
}

The second example demonstrates how to use pdfRender in conjunction with pdfXFA to generate images from a flattened XFA form. We flatten the "INPUT_XFA_FILE" into "FLATTENED_PDF_FILE" and then we render the resulting PDF into TIFF files with a custom file name "my-custom-filename-1.tiff", "my-custom-filename-2.tiff".

public void renderXFA() throws IOException, InterruptedException {
        new XFAFlattener().flatten(new FileInputStream(INPUT_XFA_FILE), new FileOutputStream(FLATTENED_PDF_FILE));

        final RenderingProperties renderingProperties = new RenderingProperties();
        renderingProperties.setImageType(PdfRenderImageType.TIFF);

        PdfToImageRenderer.renderPdf(new File(FLATTENED_PDF_FILE), new File(OUTPUT_DIRECTORY) + "/my-custom-filename-%d",
                renderingProperties);
}

This library comes as a closed source add on to iText. However, feel free to try out pdfRender! Simply contact us for a trial version.



Contact

Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now