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. 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.

XsPDF .NET PDF to Png converting library supports converting PDF document to a range of separate png images in .NET development using C# programming language. Developers can modify the output images' DPI resolution and image size.

Guide in Visual Studio
  1. Download the trial package and uncompress it.
  2. Open Visual Studio, create new C# Console Application or ASP.NET web programming.
  3. Copy "XsPDF.dll", "x86" and "x64" folders from download package to your .NET project Bin folder.
  4. In the Solution Explorer right-click on "References" and select "Add Reference". Next add references to the "System.Drawing" and "XsPDF.dll".
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