IRONSOFTWAREHOME

How to Rasterize a PDF to Images in C#

Curtis Chau
Curtis Chau
Updated: August 2, 2026

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.

  1. 1Install IronPDF with NuGet Package Manager

    PM > Install-Package IronPdf

  2. 2Copy and run this code snippet.

    IronPdf.PdfDocument.FromFile("input.pdf").RasterizeToImageFiles("page_*.png");
    C#
  3. 3Deploy to test on your live environment

    Start using IronPDF in your project today with a free trial
    arrow pointer

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.

Please note: A file extension such as .png, .jpg, or .tif is required for the FileNamePattern parameter.
Tips: The asterisk (*) character contained in the FileNamePattern will be substituted with the corresponding page numbers.
using 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");

For 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?

File Explorer showing PDF conversion output: 5 PNG files (wikipage_1-5.png) in net6.0 build directory

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.

using IronPdf;

PdfDocument pdf = PdfDocument.FromFile("url.pdf");

var image = pdf.ToBitmapHighQuality();
image[0].SaveAs("output.png");

What 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.

using 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", IronPdf.Imaging.ImageType.Png);

How 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
using 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);

How 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.

using 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));

For 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.

using 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);

What 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.

File properties showing PNG output from PDF rasterization: 353x500 pixels, 71.3 KB, with Wikipedia page thumbnail
File properties showing rasterized PDF output: 500x353 PNG, 50.5 KB, created 7/13/2023

My favorite library of this kind is IronPDF. It allows for fast and efficient manipulation of PDF files. It also has many valuable features, like exporting to PDF/A format and digitally signing PDF documents.

Milan Jovanovic

Microsoft MVP

View case study

IronOCR means we can save $40,000 annually from manual processing, while enhancing productivity and freeing up resources for high-impact tasks. I would highly recommend it.

Brent Matzelle

Chief Technology Officer, OPYN

View case study

The IronSuite play a crucial role in our operations. These are tools that increase efficiencies across the business including creating floor plans and improving inventory management.

David Jones

Lead Software Engineer, Agorus Build

View case study

Additional Considerations for PDF Rasterization

When implementing PDF to image conversion in your applications, consider these best practices:

  1. Performance Optimization: For large PDF documents or batch processing, use async and multithreading techniques to improve performance.
  2. Memory Management: High-resolution rasterization can consume significant memory. Monitor your application's memory usage and process pages in batches for large documents.
  3. Output Storage: For web applications, explore working with Azure Blob Storage for efficient image storage and retrieval.
  4. 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

What is PDF rasterization?

PDF rasterization is the process of converting a PDF document into pixel-based image formats such as PNG, JPEG, or TIFF. This transformation enables easier display, thumbnail generation, secure sharing, and image processing of PDF content.

How does IronPDF help in rasterizing PDFs?

IronPDF simplifies the rasterization of PDFs by offering methods like `RasterizeToImageFiles`, allowing easy conversion of PDF pages to image files in various formats and with customizable dimensions right from .NET applications.

Why use rasterization for PDF documents?

Rasterization is useful for generating thumbnails, creating previews, ensuring secure sharing, and enabling image-based document processing while preserving the original visual fidelity of PDF content.

What image formats does IronPDF support for exporting rasterized images?

IronPDF supports exporting rasterized images in BMP, JPEG, PNG, GIF, TIFF, and SVG formats, providing flexibility for various use cases such as printing, web display, and archival.

How can I specify output image dimensions using IronPDF?

IronPDF allows you to set custom output dimensions when rasterizing PDFs, which ensures images fit specific display requirements while preserving the original aspect ratio.

Can IronPDF rasterize specific pages of a PDF?

Yes, with IronPDF, you can specify specific pages of a PDF document to rasterize into images, which is beneficial when dealing with large documents or needing images for certain pages only.

How does DPI affect the quality of rasterized images?

DPI (dots per inch) determines the resolution of rasterized images. A higher DPI results in clearer and more detailed images but also increases file size, making it essential to balance quality and storage needs.

Where are the output images stored by default when using IronPDF?

By default, IronPDF saves output images in the application's current working directory, typically the bin/Debug or bin/Release folder, but you can specify a custom directory for storing images.

What advanced options does IronPDF offer for rasterization?

IronPDF provides advanced rasterization options such as custom output formats, page selection, DPI settings, and specifying custom image dimensions, enabling tailored solutions to fit specific project needs.

How can I convert a PDF to high-quality bitmap images using IronPDF?

Using the `ToBitmapHighQuality` method in IronPDF, you can convert PDFs to high-quality bitmap images encoded in the BMP format, ensuring sharp image quality suitable for high-resolution needs.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Ready to Get Started?

Nuget Downloads 20,809,720Version:2026.9just released

Get your FREE

30-day Trial Key instantly.

bullet_checkedNo credit card or account creation required
bullet_testTest in production
without watermarks
bullet_calendar30 days fully
functional product
bullet_support24/5 technical
support during trial
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronPdf
nuget.org/packages/IronPdf/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronPdf"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

or download Windows Installer here.

  1. Download and unzip IronPDF to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronPdf.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required