How to Rasterize a PDF to Images in C#
IronPDF provides a simple way to convert PDF pages into image formats like PNG, JPEG, or TIFF using the RasterizeToImageFiles method, enabling easy integration of PDF-to-image conversion in your .NET applications for thumbnails, previews, or image processing.
Rasterizing a PDF converts it into a pixel-based image format like JPEG or PNG. This process transforms each page into a static image represented by pixels. Rasterization enables PDF content display, thumbnail generation, image processing, and secure document sharing.
With IronPDF, you can programmatically convert PDFs to images. Whether you need to incorporate PDF rendering into your application, generate image previews, perform image-based operations, or enhance document security, IronPDF provides the necessary tools. The library supports various image formats and provides control over output quality, dimensions, and page selection. You can leverage IronPDF's Chrome PDF Rendering Engine for accurate rendering that preserves the original document's appearance.
Quickstart: Effortless PDF Rasterization in .NET with IronPDF
Convert PDF pages to images using IronPDF's simple API. This quickstart demonstrates how to load a PDF and export each page as an image file, allowing you to integrate rasterization capabilities into your .NET applications. Perfect for generating thumbnails, enhancing document security, or preparing files for further processing.
Get started making PDFs with NuGet now:
Install IronPDF with NuGet Package Manager
Copy and run this code snippet.
IronPdf.PdfDocument.FromFile("input.pdf").RasterizeToImageFiles("page_*.png");Deploy to test on your live environment
Minimal Workflow (5 steps)
- Download the C# library for rasterizing PDF to images
- Load an existing PDF or create a PDF from a file, HTML, or URL
- Invoke the
RasterizeToImageFilesmethod to export images from the PDF document - Specify the DPI to improve clarity
- Specify custom output image dimensions according to your requirements
How Do I Convert PDF Pages to Images in C#?
The RasterizeToImageFiles method exports images from a PDF document. This method is available on the PdfDocument object, whether importing a PDF document file locally or rendering it from an HTML file to PDF conversion guide, HTML string to PDF conversion guide, or URL to PDF conversion guide.
The method provides flexibility in generating images from PDF documents. You can convert entire documents or specific pages, control the output format and quality, and specify custom dimensions for the resulting images. This makes it ideal for various use cases, from creating thumbnail previews to generating high-resolution images for printing.
:path=/static-assets/pdf/content-code-examples/how-to/rasterize-pdf-to-images-rasterize.csusing IronPdf;
// Instantiate Renderer
ChromePdfRenderer renderer = new ChromePdfRenderer();
// Render PDF from web URL
PdfDocument pdf = renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Main_Page");
// Export images from PDF
pdf.RasterizeToImageFiles("wikipage_*.png");IRON VB CONVERTER ERROR developers@ironsoftware.comFor more complex PDF generation scenarios, explore converting CSHTML to PDF or learn about custom rendering options to fine-tune your PDF creation process before rasterization.
Where Are the Output Images Saved?

By default, output images are saved to the application's current working directory, typically the bin/Debug or bin/Release folder of your project. You can specify an absolute or relative path to save images to a custom location. For example, @"C:\Output\page_*.png" saves images to the C:\Output directory.
If form field values should be visible in output images, flatten the PDF before converting it to an image or pass true to the Flatten parameter of the method. Forms will not be detectable after using the Flatten method. Learn more about flattening PDFs to understand the process better.
Learn how to fill and edit PDF forms programmatically in the article: "How to Fill and Edit PDF Forms."
How Can I Generate High-Quality Bitmap Images?
To retain the original resolution of images when converting to a Bitmap, use ToBitmapHighQuality instead of ToBitmap. The ToBitmap method returns an image decoded from JPEG, while the ToBitmapHighQuality method returns an image decoded from the BMP format.
The BMP format stores raw pixel data, resulting in sharper images but larger file sizes. JPEG uses lossy compression, significantly reducing file size at the cost of slight blurriness. For most use cases like printing and viewing PDFs, JPEG image quality is sufficient. For PDFs requiring high visual fidelity, explore our guide on pixel-perfect HTML formatting.
:path=/static-assets/pdf/content-code-examples/how-to/rasterize-pdf-to-images-to-bitmap-high-quality.csusing IronPdf;
PdfDocument pdf = PdfDocument.FromFile("url.pdf");
var image = pdf.ToBitmapHighQuality();
image[0].SaveAs("output.png");IRON VB CONVERTER ERROR developers@ironsoftware.comWhat Advanced Options Are Available for PDF Rasterization?
Let's explore the additional parameters available for the RasterizeToImageFiles method. IronPDF provides comprehensive control over the rasterization process, allowing customization according to specific requirements.
Which Image Formats Can I Export To?
Another parameter allows you to specify file types for output images. Supported formats include BMP, JPEG, PNG, GIF, TIFF, and SVG. Each type has a corresponding method that can be directly invoked from the PdfDocument object:
ToBitmap: Rasterizes the PDF into individual AnyBitmap objects, one Bitmap per page.ToJpegImages: Renders PDF pages as JPEG files and saves to disk.ToPngImages: Renders PDF pages as PNG files and saves to disk.ToTiffImages: Renders PDF pages as single-page TIFF files and saves to disk.ToMultiPageTiffImage: Renders PDF pages as a single multi-page TIFF file.SaveAsSvg: Converts the PDF to SVG format and saves to the specified path.ToSvgString: Converts a specific PDF page to SVG format and returns as a string.
For working with vector graphics, explore our guide on using SVG graphics in PDF generation, which complements SVG export functionality.
:path=/static-assets/pdf/content-code-examples/how-to/rasterize-pdf-to-images-image-type.csHow Do I Improve Image Clarity with DPI Settings?
The default DPI of 96 may produce blurry output images. To improve clarity, specify a higher DPI value when rasterizing. DPI (dots per inch) directly affects resolution and file size. Higher DPI values produce clearer images but result in larger file sizes.
Common DPI settings:
- 96 DPI: Standard screen resolution for web display
- 150 DPI: Good for general document viewing
- 300 DPI: High quality for printing
- 600 DPI: Professional printing quality
:path=/static-assets/pdf/content-code-examples/how-to/rasterize-pdf-to-images-dpi.csusing IronPdf;
// Instantiate Renderer
ChromePdfRenderer renderer = new ChromePdfRenderer();
// Render PDF from web URL
PdfDocument pdf = renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Main_Page");
// Export images from PDF with DPI 150
pdf.RasterizeToImageFiles("wikipage_*.png", DPI: 150);IRON VB CONVERTER ERROR developers@ironsoftware.comHow Do I Convert Specific Pages to Images?
You can specify which pages of the PDF document to rasterize into images. The example below generates images of PDF pages 1-3. This feature is useful for creating thumbnails of specific pages or when working with large PDF documents where only certain pages need to be images.
:path=/static-assets/pdf/content-code-examples/how-to/rasterize-pdf-to-images-page-indexes.csusing IronPdf;
using System.Linq;
// Instantiate Renderer
ChromePdfRenderer renderer = new ChromePdfRenderer();
// Render PDF from web URL
PdfDocument pdf = renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Main_Page");
// Export images from PDF page 1_3
pdf.RasterizeToImageFiles("wikipage_*.png", Enumerable.Range(1, 3));IRON VB CONVERTER ERROR developers@ironsoftware.comFor advanced page manipulation, explore our guides on adding, copying, and deleting pages or splitting PDFs.
How Do I Control Output Image Dimensions?
When converting PDF documents to images, you can customize the height and width of output images. The specified values represent maximum dimensions while preserving the aspect ratio of the original document. For a portrait PDF document, the specified height value will be exact, while the width adjusts to maintain the correct aspect ratio.
This feature is essential when images must fit specific dimensions for web display, thumbnails, or other applications requiring consistent sizing. Aspect ratio preservation ensures content doesn't appear stretched or distorted.
:path=/static-assets/pdf/content-code-examples/how-to/rasterize-pdf-to-images-image-dimensions.csusing IronPdf;
// Instantiate Renderer
ChromePdfRenderer renderer = new ChromePdfRenderer();
// Render PDF from web URL
PdfDocument pdf = renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Main_Page");
// Export images from PDF
pdf.RasterizeToImageFiles("wikipage_*.png", 500, 500);IRON VB CONVERTER ERROR developers@ironsoftware.comWhat Happens to Aspect Ratios When Setting Dimensions?
Output image dimensions are specified using width by height format (width x height). IronPDF intelligently handles aspect ratio preservation to ensure images maintain original proportions.

Portrait

Landscape
Additional Considerations for PDF Rasterization
When implementing PDF to image conversion in your applications, consider these best practices:
Performance Optimization: For large PDF documents or batch processing, use async and multithreading techniques to improve performance.
Memory Management: High-resolution rasterization can consume significant memory. Monitor your application's memory usage and process pages in batches for large documents.
Output Storage: For web applications, explore working with Azure Blob Storage for efficient image storage and retrieval.
- Quality vs. File Size: Balance DPI settings based on your use case. Higher DPI produces better quality but larger files, impacting storage and bandwidth requirements.
By leveraging IronPDF's comprehensive rasterization capabilities, you can convert PDF documents to various image formats while maintaining full control over quality, dimensions, and output specifications. Whether building a document management system, creating preview functionality, or generating thumbnails, IronPDF provides the tools for efficient PDF-to-image conversion.
Frequently Asked Questions
How do I convert PDF pages to images in C#?
With IronPDF, you can convert PDF pages to images using the RasterizeToImageFiles method. Simply load your PDF document and call this method to export pages as PNG, JPEG, or TIFF images. The method is available on the PdfDocument object and supports converting entire documents or specific pages with custom dimensions and quality settings.
What image formats are supported for PDF conversion?
IronPDF supports converting PDFs to multiple image formats including PNG, JPEG, and TIFF. The format is automatically determined by the file extension you specify in the RasterizeToImageFiles method, making it easy to generate images in your preferred format.
Can I control the quality and dimensions of converted images?
Yes, IronPDF provides full control over output quality and dimensions when rasterizing PDFs. You can specify custom DPI settings to improve clarity and set specific output dimensions according to your requirements, ensuring the generated images meet your exact specifications.
What are common use cases for PDF to image conversion?
IronPDF's rasterization feature is ideal for generating thumbnails, creating document previews, enabling secure document sharing (as images can't be easily edited), performing image-based operations, and integrating PDF rendering into applications that require image formats.
How accurate is the PDF to image conversion?
IronPDF uses the Chrome PDF Rendering Engine to ensure accurate rendering that preserves the original document's appearance. This means fonts, layouts, graphics, and formatting are faithfully reproduced in the resulting images.
Can I convert specific pages of a PDF to images?
Yes, IronPDF's RasterizeToImageFiles method provides flexibility to convert specific pages or ranges of pages from a PDF document, not just the entire document. This allows you to selectively export only the pages you need as images.






