This quick guide provides details on how to convert PDF to image in C#. You can set resolution, height, width and other properties like setting default font, scaling images to fit the page width, and many others. For converting a PDF page to image C# code is used and detailed steps are given below to convert a PDF file to a PNG image.
Steps to Convert PDF to Image in C#
- Install Aspose.PDF using NuGet package manager to convert PDF to image
- Load the source PDF file into the Document class object for converting to image
- Create the Resolution object to set output image resolution
- Initialize PngDevice class object using the resolution object
- Parse through all the pages in the source PDF using Document.Pages collection
- Call PngDevice.Process function to convert each PDF page to image and save on disk
Here you get the step-by-step details to render the PDF to image in C# by adding necessary references and then loading the target PDF. You can set different configurations for all the output images file and parse through all the PDF file pages for converting to image. In the end, each converted image is saved to a separate file on disk.
Code to Export PDF to image in C#
This code uses the Document class object to load the source PDF where the Document class contains pages collection for iteration. To set different properties of the output images, Resolution and PngDevice objects are declared that support setting a variety of parameters like image resolution, height, width, BarcodeOptimization, InterpolationHighQuality, and OptimizeDimensions. Note that you can use BmpDevice, EmfDevice, GifDevice, and many others to create different types of images.
We have learned the process to transfer PDF pages to images using C#. If you want to learn the creation of PDF files from scratch, refer to the article on how to create PDF in C#.