Click or drag to resize
Getting Started with PDF To Image Converter for .NET

The ExpertPdf PDF To Image Converter for .NET can be used in any type of .NET application to convert PDF pages to images. The product archive contains the development libraries for .NET 2.0 or .NET 4.0 and a ready to use Windows Forms application. The full C# and VB.NET source code for the sample is available in the Samples folder.

PDF To Image Converter Development Library

The PDF To Image Converter development library 'pdftoimage.dll' is a strong named .NET 2.0 or .NET 4.0 assembly, for 32 or 64 bit operating systems, that can be linked into any .NET application, either Windows Forms and Console applications or ASP.NET 2.0 or 4.0 web sites.

Caution note Caution

There are different versions of pdftoimage.dll for x86 and x64 systems. Make sure you use the correct version:

  • pdftoimage.net20.x86.dll - .NET 2.0 / 32 bit systems

  • pdftoimage.net20.x64.dll - .NET 2.0 / 64 bit systems

  • pdftoimage.net40.x86.dll - .NET 4.0 / 32 bit systems

  • pdftoimage.net40.x64.dll - .NET 4.0 / 64 bit systems

The main class in the assembly is PdfToImageConverter. This class exposes an overloaded method ConvertToImages() that you can use to convert PDF pages from a PDF stream or from a PDF file to images. The generated images are returned as an in-memory array of .NET system Image objects.

You have the posibility to save the generated images in a folder if the ConvertToImagesInFolder() methods are used. The images will be saved into the folder specified by ImagesPath property, in the format specified by ImagesFormat property.

The PdfToImageConverter class also defines a few other properties controlling the conversion process. You can specify for example the range of PDF pages to be extracted by using the StartPageNumber and EndPageNumber properties, a user password to be used to open a password protected PDF document using the UserPassword property, the folder where the images will be saved using the ImagesPath parameter, the images file name prefix using the ImagesPrefix property and the image format, which can be any format supported by .NET framework, using the ImagesFormat property.

Code Sample

Below there is an example of code taken from the sample application:

// create the converter object and set the user options
PdfToImageConverter pdfToImageConverter = new PdfToImageConverter();

if (licenseKey != null)
    pdfToImageConverter.LicenseKey = licenseKey; // license key

pdfToImageConverter.ImagesFormat = imgFormat; // image format
pdfToImageConverter.ColorSpace = colorSpace; // image color space
pdfToImageConverter.StartPageNumber = startPageNumber; // start page number
pdfToImageConverter.EndPageNumber = endPageNumber; // end page number
pdfToImageConverter.Resolution = resolution; // image resolution
pdfToImageConverter.ImagesPath = outputPath; // images output path

if (password != null)
    pdfToImageConverter.UserPassword = password; // PDF password

// convert the PDF pages to images
pdfToImageConverter.ConvertToImagesInFolder(pdfFileName);

In this sample, an instance of the PdfToImageConverter class is constructed and the converter object properties are set based on the user input. Then the ConvertToImagesInFolder method is called to convert the PDF document pages to images from the source PDF document.

Licensing

The LicenseKey property of the PdfToImageConverter class should be set with the license key string you have received after the product purchase.