
You may need to share the pages of PDF documents as image files with others. As a C# developer, you can easily convert PDF files to PNG, JPG, TIFF, or BMP programmatically in your .NET applications. In this article, you will learn how to convert PDF to Images using C#.
The following topics are discussed/covered in this article:
- PDF to Image Conversion C# API
- Convert PDF to PNG Images using C#
- Convert PDF to JPG Images using C#
- PDF to BMP Conversion in C#
- PDF to TIFF Conversion in C#
- Extract Images from PDF documents using C#
PDF to Image Conversion C# API
For converting PDF to images, I will be using Aspose.PDF for .NET API. It is a powerful PDF file management API that lets you manipulate PDF documents from within your .NET applications. It allows you to create, modify, convert, render, secure and print documents without using Adobe Acrobat.
You can either download the DLL of the API or install it using the NuGet.
Install-Package Aspose.Pdf
C# Convert PDF to PNG Images - Just a Few Steps
You can convert PDF files to PNG images programmatically by following the steps given below:
- Create an instance of the Document class with the input PDF file path.
- Loop through all the pages of the PDF using Document.Pages collection and do the following: 2.1. Create an instance of the Resolution class and set its value. 2.2. Create an instance of the PngDevice class and pass Width, Height and Resolution object. 2.3. Call the Process(Page, String) method with the page number and the output PNG image path to convert the page to a PNG.
The following code sample shows how to convert PDF pages to PNG images using C#.
// Open document | |
Document pdfDocument = new Document("C:\\Files\\sample.pdf"); | |
foreach (var page in pdfDocument.Pages) | |
{ | |
// Define Resolution | |
Resolution resolution = new Resolution(300); | |
// Create Png device with specified attributes | |
// Width, Height, Resolution | |
PngDevice PngDevice = new PngDevice(500, 700, resolution); | |
// Convert a particular page and save the image to stream | |
PngDevice.Process(pdfDocument.Pages[page.Number], "C:\\Files\\image" + page.Number + "_out" + ".Png"); | |
} |

Convert PDF to PNG Images using C#
The Document class represents the PDF document. It provides several properties and methods to perform various functionalities. The Document.Pages collection is a collection of document pages and the page numbering starts from 1 in the collection. The Resolution class defines the image resolution. The PngDevice class allows saving pages of the PDF document into PNG images. This class provides the following methods to save pages into PNG images:
- Process(Page, String) — Performs some operation on the given page and saves results into the file at given path.
- Process(Page, Stream) — Converts the page into PNG and saves it in the output stream.
C# Convert PDF to JPG Images - Step by Step
You can convert PDF files to JPG images programmatically by following the steps given below:
- Create an instance of the Document class with the input file path.
- Loop through all the pages of the PDF using Document.Pages collection and do the following: 2.1. Create an instance of the Resolution class and set its value. 2.2. Create an instance of the JpegDevice class and pass Width, Height and Resolution object. 2.3. Call the Process(Page, String) method with the page number and the output JPG image path to convert the page to a JPG.
The following code sample shows how to convert PDF pages to JPG images using C#.
// Open document | |
Document pdfDocument = new Document("C:\\Files\\sample.pdf"); | |
foreach (var page in pdfDocument.Pages) | |
{ | |
// Define Resolution | |
Resolution resolution = new Resolution(300); | |
// Create Jpeg device with specified attributes | |
// Width, Height, Resolution | |
JpegDevice JpegDevice = new JpegDevice(500, 700, resolution); | |
// Convert a particular page and save the image to stream | |
JpegDevice.Process(pdfDocument.Pages[page.Number], "C:\\Files\\image" + page.Number + "_out" + ".Jpg"); | |
} |

Convert PDF to JPG Images using C#
C# PDF to BMP Conversion - Short Walkthrough
You can convert PDF files to BMP images programmatically by following the steps given below:
- Create an instance of the Document class with the input file path.
- Loop through all the pages of the PDF using Document.Pages collection and do the following: 2.1 Create an instance of the Resolution class and set its value. 2.2 Create an instance of the BmpDevice class and pass Width, Height and Resolution object. 2.3 Call the Process(Page, String) method with the page number and the output BMP image path to convert the page to a BMP.
The following code sample shows how to convert PDF pages to BMP images using C#.
// Open document | |
Document pdfDocument = new Document("C:\\Files\\sample.pdf"); | |
foreach (var page in pdfDocument.Pages) | |
{ | |
// Define Resolution | |
Resolution resolution = new Resolution(300); | |
// Create PNG device with specified attributes | |
// Width, Height, Resolution | |
BmpDevice BmpDevice = new BmpDevice(500, 700, resolution); | |
// Convert a particular page and save the image to stream | |
BmpDevice.Process(pdfDocument.Pages[page.Number], "C:\\Files\\image" + page.Number + "_out" + ".bmp"); | |
} |

PDF to BMP Conversion using C#
C# Tutorial: How to Convert PDF to TIFF
You can convert PDF files to TIFF programmatically by following the steps given below:
- Create an instance of the Document class with the input file path.
- Initialize an instance of the Resolution class and set its value.
- Create an instance of the TiffSettings class.
- Set various properties such as Compression, Depth, Shape, and SkipBlankPages, etc.
- Create an instance of the TiffDevice class with the Resolution and the TiffSettings objects.
- Call the Process(Document, String) method with the Document object and the output TIFF file path to convert the document to a TIFF.
The following code sample shows how to convert a PDF file to a TIFF using C#.
// Open document | |
Document pdfDocument = new Document("C:\\Files\\sample.pdf"); | |
// Define Resolution | |
Resolution resolution = new Resolution(300); | |
// Create TiffSettings object | |
TiffSettings tiffSettings = new TiffSettings | |
{ | |
Compression = CompressionType.None, | |
Depth = ColorDepth.Default, | |
Shape = ShapeType.Portrait, | |
SkipBlankPages = false | |
}; | |
// Create TIFF device | |
TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings); | |
// Convert a particular page and save the image to stream | |
tiffDevice.Process(pdfDocument, "C:\\Files\\AllPagesToTIFF_out.tif"); |

PDF to TIFF Conversion using C#
The TiffSettings class provides several settings for converting a PDF to TIFF. You can set Brightness, Compression, CoordinateType, Depth, Margins, Shape, and SkipBlankPages while converting PDF to TIFF.
C# Extract Images from PDF Documents
You can extract all the images from any PDF file programmatically by following the steps given below:
- Create an instance of the Document class with the input file path.
- For each page, create XImage instance for every image in the Page.Resources.Images collection.
- Create an instance of the FileStream class with the output image file path.
- Call the Save() method with the FileStream object to save the image
- Finally, close the FileStream using Close() method.
The following code sample shows how to extract images from a PDF document using C#.
// Open document | |
Document pdfDocument = new Document("C:\\Files\\sample.pdf"); | |
// Loop through pages | |
foreach (var page in pdfDocument.Pages) | |
{ | |
int imageCounter = 1; | |
// Loop through all images | |
foreach (XImage image in page.Resources.Images) | |
{ | |
// Create file stream for image | |
FileStream outputImage = new FileStream(String.Format("C:\\Files\\Page{0}_Image{1}.jpg", page.Number, imageCounter), FileMode.Create); | |
// Save output image | |
image.Save(outputImage); | |
// Close stream | |
outputImage.Close(); | |
imageCounter++; | |
} | |
} |

Extract Images from PDF Documents using C#
The XImage class represents the image X-Object. It provides several properties and methods to work with images. The XImage class provides the following methods to save the image object:
- Save(Stream) — Saves image data into stream as JPEG image.
- Save(Stream, ImageFormat) — Saves image into stream with requested format.
- The Save(Stream, Int32) method — Saves image data into stream as JPEG image with specified resolution.
- The Save(Stream, ImageFormat, Int32) method — Saves image into stream with requested format and specified resolution.
The Page.Resources.Images collection represents the collection of images for the specific page.
Get a Free License
You can try the API without evaluation limitations by requesting a free temporary license.
Conclusion
In this article, you have learned how to convert PDF file pages to images using C#. You have also learned how to convert PDF to PNG, PDF to JPG, PDF to BMP, and PDF to TIFF programmatically. Moreover, you have learned how to extract images from a PDF file using C#. The API also offers compression options, table creation & manipulation, graph & image functions, extensive hyperlink functionality, stamp and watermark tasks, extended security controls and custom font handling. You can learn more about Aspose.PDF for .NET API using the documentation. In case of any ambiguity, please feel free to contact us on the forum.