PDF to Image – Convert PDF pages to images 6

PDF to image, the conversion of PDF pages to images, is one of the most requested features and it is now available in XFINIUM.PDF 5.0 Professional Edition.
We have implemented the conversion of PDF pages to images through our custom Xfinium.Graphics PDF rendering engine. It has been developed from scratch and it has been developed to be cross-platform. This allowed us to support PDF to image capabilities on all platforms.
The conversion of a PDF page to image is a simple 3 step process:
– load the document
– create a renderer for the page
– convert the page to image

The library supports converting PDF pages to RAW images.

For RAW images the RGBA layout is used by default but the library provides support for RGBA, BGRA and ARGB rendering surfaces in case you need different color layout.
The code below uses an ARGB rendering surface for converting the PDF to image.

The rendering surface can use either an array of bytes or an array of integers as storage. You select the appropriate storage based on what you want to do with the rendered image.
For example if you’re working with WriteableBitmaps in Silverlight you should use an int based storage because it will be easier to transfer the pixels from the rendering surface to the WriteableBitmap.

The PDF rendering engine is portable and this means almost identical results on all platforms. Why almost? The PDF rendering engine compiled for Windows Forms and WPF has access to the fonts installed on the local machine. If the PDF files use non-embedded fonts then the WinForms and WPF versions will retrieve the fonts from the local machine while the other versions will use a default Helvetica font.
Fell free to contact us with any questions you might have about PDF rendering or if you have a PDF file that is not rendered correctly.

6 thoughts on “PDF to Image – Convert PDF pages to images

  1. Reply Michał Oct 17,2017 6:19 pm

    Hey,

    I’m using below code to open pdf, convert it to image and return as byte array. I do it on Xamarin.iOS and use the byte array as Image source to show it, sadly I get only white image, nothing else. The array is not empty, I get no exceptions:

    PdfFixedDocument doc = new PdfFixedDocument(NSBundle.MainBundle.BundlePath + “/” + path);

    PdfPageRenderer renderer = new PdfPageRenderer(doc.Pages[0]);
    var pageImage = renderer.ConvertPageToImage(96);

    return pageImage.DataProvider.CopyData().ToArray();

    do you have any idea? I’d love to buy your product after I get a working proof of concept

    Cheers,
    Michał

  2. Reply Michał Oct 18,2017 8:51 am

    Is there any tutorial how to use it in Xamarin Forms project?

Leave a Reply