Save a PDF document as a set of separate PNG images.

There are times when a full PDF document is not going to work. It might be more than you need, or you might just need a couple images from the document. Among various image file formats, PNG is, to some degree, the improved format for GIF, which is the most popular lossless image compression format widely used on the Internet. If you just want to render and convert PDF document to PNG image file format, then try XsPDF .NET PDF to Png converting library.

XsPDF .NET PDF to Image SDK provides advanced conversion APIs for PDF to Png conversion. You can easily integrate high quality conversion functionality into your C# programming projects. This article will show you a tutorial about how to convert PDF pages to a group of high quality png image files in .NET C# class application.

Guide in Visual Studio
  1. Download the free package of XsPDF .NET PDF to Image SDK.
  2. Open Visual Studio and create a C# Console Application.
  3. Copy "XsPDF.dll" and "XsPDF.Native.dll" to the Bin folder of your project. We prepared "XsPDF.Native.dll" for both x86 and x64 systems.
  4. To use the mature APIs, you need to add project reference to "XsPDF.dll" and "System.Drawing".
How to Convert PDF to PNG in C#.NET class?

// Create a PDF converter instance by loading a local file 
PdfImageConverter pdfConverter = new PdfImageConverter("sample.pdf");

// Set the dpi, the output image will be rendered in such resolution
pdfConverter.DPI = 96;

// the output image will be rendered to grayscale image or not
pdfConverter.GrayscaleOutput = false;

for (int i = 0; i < pdfConverter.PageCount; i++)
    // Convert each pdf page to png image with original page size
    //Image pageImage = pdfConverter.PageToImage(i);
    // Convert pdf to png in customized image size
    Image pageImage = pdfConverter.PageToImage(i, 500, 800);

    // Save converted image to png format
    pageImage.Save("Page " + i + ".png", ImageFormat.Png);

More PDF tutorial