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 Framework or .NET Core application to convert PDF pages to images. There are 2 ways to install ExpertPdf PdfToImage Library:
Using a NuGet package (.NET Framework and .NET Core)
Downloading assemblies
The easiest way to install ExpertPdf PdfToImage is by using a Nuget Package. Create your project, go to Nuget Package Manager and install one of the following packages:
.NET Framework and .NET Core version - AnyCPU - ExpertPdf.PdfToImage: https://www.nuget.org/packages/ExpertPdf.PdfToImage/.
.NET Framework and .NET Core version - x64 optimized version - ExpertPdf.PdfToImage.x64: https://www.nuget.org/packages/ExpertPdf.PdfToImage.x64/.
Note 1: If the x64 version is used, the application needs to target x64 platform and it needs to run in an x64 worker process.
Note 2: The .NET Core version is for .NET Core 2.0 or above through .NET Standard 2.0. Currently it requires a Windows system to run. It does not work on Linux or Mac or Xamarin.
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.
Here are the steps needed to get started working with the library referencing the assembly directly:
Add eppdftoimage.dll and eptools.dep to the bin folder of your application.
Add a reference in the project to eppdftoimage.dll.
Write your code (see the samples and the API reference for help).
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 Framework or .NET Core application, either Windows Forms and Console applications or ASP.NET 2.0 or 4.0 web sites.
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.
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.
The LicenseKey property of the PdfToImageConverter class should be set with the license key string you have received after the product purchase.