IronPDF How-Tos Image from PDF How to Rasterize a PDF to Images ByChaknith Bin July 12, 2023 Updated June 22, 2025 Share: Rasterizing a PDF file involves converting it into a pixel-based image format like JPEG or PNG. This process transforms each page of the PDF into a static image, where the content is represented by pixels. Rasterization offers several advantages, including the ability to display PDF content, generate thumbnails, perform image processing, and facilitate secure document sharing.With IronPDF, you can easily and 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 has you covered. View the IronPDF YouTube Playlist Go from PDF to Image in Seconds! IronPdf.PdfDocument .FromFile("path/to/example/pdf.pdf") .RasterizeeToImageFiles("image_*.png"); Install with NuGet PM > Install-Package IronPdf Get started with IronPDF Start using IronPDF in your project today with a free trial. First Step: Start for Free How to Rasterize a PDF to Images in C# 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 RasterizeToImageFiles method to export images from the PDF document Specify the DPI to improve clarity Specify custom output image dimensions according to your requirements Rasterize a PDF to Images Example The RasterizeToImageFiles method is utilized to export images from a PDF document. This method is available on the PdfDocument object, whether you are 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. Please noteA file extension such as .png, .jpg, or .tif is required for the FileNamePattern parameter. TipsThe asterisk (*) character contained in the FileNamePattern will be substituted with the corresponding page numbers. :path=/static-assets/pdf/content-code-examples/how-to/rasterize-pdf-to-images-rasterize.cs // Import the IronPdf library to work with PDF rendering and manipulation using IronPdf; // Instantiate a ChromePdfRenderer object to render PDFs with the Chrome rendering engine ChromePdfRenderer renderer = new ChromePdfRenderer(); // Render a PDF document from a specified web URL. // The URL used here is Wikipedia's main page. PdfDocument pdf = renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Main_Page"); // Export each page of the PDF as separate image files. // The images will be saved with a naming pattern "wikipage_*.png", // where the asterisk (*) will be replaced by the page number of each page in the PDF. pdf.RasterizeToImageFiles("wikipage_*.png"); ' Import the IronPdf library to work with PDF rendering and manipulation Imports IronPdf ' Instantiate a ChromePdfRenderer object to render PDFs with the Chrome rendering engine Private renderer As New ChromePdfRenderer() ' Render a PDF document from a specified web URL. ' The URL used here is Wikipedia's main page. Private pdf As PdfDocument = renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Main_Page") ' Export each page of the PDF as separate image files. ' The images will be saved with a naming pattern "wikipage_*.png", ' where the asterisk (*) will be replaced by the page number of each page in the PDF. pdf.RasterizeToImageFiles("wikipage_*.png") $vbLabelText $csharpLabel Output Folder If the form fields' values are intended to be visible in the output images, please 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 how to fill and edit PDF forms programmatically in the following article: "How to Fill and Edit PDF Forms." Rasterize a PDF to Images Advanced Example Let's explore the additional parameters available for the RasterizeToImageFiles method. Specify Image Type Another parameter provided by the method allows you to specify the file types for the output images. We support BMP, JPEG, PNG, GIF, TIFF, and SVG formats. Each type has its corresponding method that can be directly invoked from the PdfDocument object. Here are the available methods: ToBitmap: Rasterizes (renders) the PDF into individual AnyBitmap objects, with one Bitmap for each page. ToJpegImages: Renders the PDF pages as JPEG files and saves them to disk. ToPngImages: Renders the PDF pages as PNG (Portable Network Graphic) files and saves them to disk. ToTiffImages: Renders the PDF pages as single-page TIFF files and saves them to disk. ToMultiPageTiffImage: Renders the PDF pages as a single multi-page TIFF file and saves it to disk. SaveAsSvg: Converts the PDF document to an SVG format and saves it to the specified file path. ToSvgString: Converts a specific page of the PDF document to an SVG format and returns it as a string. :path=/static-assets/pdf/content-code-examples/how-to/rasterize-pdf-to-images-image-type.cs Specify DPI When using the default DPI of 96, the output images may appear blurry. To improve clarity, it is important to specify a higher DPI value when rasterizing. :path=/static-assets/pdf/content-code-examples/how-to/rasterize-pdf-to-images-dpi.cs using IronPdf; // Instantiate a Chrome Pdf Renderer var renderer = new ChromePdfRenderer(); // Render a PDF from a specified web URL and store it in a PdfDocument object var pdf = renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Main_Page"); // Export images from the rendered PDF with a DPI of 150 // The images will be saved with names starting with "wikipage_" followed by an index starting from 0 pdf.RasterizeToImageFiles("wikipage_*.png", dpi: 150); Imports IronPdf ' Instantiate a Chrome Pdf Renderer Private renderer = New ChromePdfRenderer() ' Render a PDF from a specified web URL and store it in a PdfDocument object Private pdf = renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Main_Page") ' Export images from the rendered PDF with a DPI of 150 ' The images will be saved with names starting with "wikipage_" followed by an index starting from 0 pdf.RasterizeToImageFiles("wikipage_*.png", dpi:= 150) $vbLabelText $csharpLabel Specify Pages Index It is also possible to specify which pages of the PDF document you want to rasterize into image(s). In the example below, images of PDF document pages 1-3 will be generated. :path=/static-assets/pdf/content-code-examples/how-to/rasterize-pdf-to-images-page-indexes.cs using IronPdf; using System.Linq; // Instantiate the PDF Renderer ChromePdfRenderer renderer = new ChromePdfRenderer(); // Render a PDF document from a web URL. // The URL provided is the main page of Wikipedia. PdfDocument pdf = renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Main_Page"); // Export images from PDF pages 1 to 3. // The resulting images will be named in the pattern "wikipage_1.png", "wikipage_2.png", etc. // Note: Page numbers in PDFs are generally 1-based. pdf.RasterizeToImageFiles("wikipage_*.png", Enumerable.Range(1, 3)); Imports IronPdf Imports System.Linq ' Instantiate the PDF Renderer Private renderer As New ChromePdfRenderer() ' Render a PDF document from a web URL. ' The URL provided is the main page of Wikipedia. Private pdf As PdfDocument = renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Main_Page") ' Export images from PDF pages 1 to 3. ' The resulting images will be named in the pattern "wikipage_1.png", "wikipage_2.png", etc. ' Note: Page numbers in PDFs are generally 1-based. pdf.RasterizeToImageFiles("wikipage_*.png", Enumerable.Range(1, 3)) $vbLabelText $csharpLabel Specify Image Dimensions When converting PDF documents to images, you have the flexibility to customize the height and width of the output images. The specified height and width values represent the maximum dimensions, while ensuring that the aspect ratio of the original document is preserved. For instance, in the case of a portrait PDF document, the specified height value will be exact, while the width value may be adjusted to maintain the correct aspect ratio. :path=/static-assets/pdf/content-code-examples/how-to/rasterize-pdf-to-images-image-dimensions.cs using IronPdf; // Instantiate a ChromePdfRenderer to render web pages to PDF. ChromePdfRenderer renderer = new ChromePdfRenderer(); try { // Render the PDF from a web URL. // This example uses the Wikipedia main page as the target. // The RenderUrlAsPdf method accesses the URL and converts the page into a PdfDocument object. PdfDocument pdf = renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Main_Page"); // Export images from the PDF document. // The RasterizeToImageFiles method will convert each page of the PdfDocument into an image file. // The file names are specified by the pattern "wikipage_*.png". The '*' will be replaced with the page number. // The width and height for the images are set to 500x500 pixels. pdf.RasterizeToImageFiles("wikipage_*.png", 500, 500); } catch (Exception ex) { // Provides information if an error occurs during rendering or rasterizing. Console.WriteLine($"An error occurred: {ex.Message}"); } Imports IronPdf ' Instantiate a ChromePdfRenderer to render web pages to PDF. Private renderer As New ChromePdfRenderer() Try ' Render the PDF from a web URL. ' This example uses the Wikipedia main page as the target. ' The RenderUrlAsPdf method accesses the URL and converts the page into a PdfDocument object. Dim pdf As PdfDocument = renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Main_Page") ' Export images from the PDF document. ' The RasterizeToImageFiles method will convert each page of the PdfDocument into an image file. ' The file names are specified by the pattern "wikipage_*.png". The '*' will be replaced with the page number. ' The width and height for the images are set to 500x500 pixels. pdf.RasterizeToImageFiles("wikipage_*.png", 500, 500) Catch ex As Exception ' Provides information if an error occurs during rendering or rasterizing. Console.WriteLine($"An error occurred: {ex.Message}") End Try $vbLabelText $csharpLabel Specifications for Output Images The dimensions for the output images are specified using the width by height format, denoted as width x height. Portrait Landscape Frequently Asked Questions What is rasterization in the context of PDFs? Rasterization is the process of converting a PDF file into a pixel-based image format like JPEG or PNG. This involves transforming each page of the PDF into a static image represented by pixels. Why would I need to rasterize a PDF? Rasterizing a PDF allows for displaying PDF content as images, generating thumbnails, performing image processing, and enhancing document security. How can I convert a PDF to images programmatically? Using IronPDF, you can programmatically convert PDFs to images by loading a PDF document and invoking the RasterizeToImageFiles method to export images from the PDF. What image formats are supported for PDF rasterization? IronPDF supports BMP, JPEG, PNG, GIF, TIFF, and SVG formats for rasterizing PDFs to images. Can I specify the DPI when converting a PDF with a library? Yes, you can specify a higher DPI to improve the clarity of the output images when rasterizing a PDF using IronPDF. Is it possible to convert specific pages of a PDF to images? Yes, you can specify which pages of the PDF document you want to rasterize into images using IronPDF. How can I customize the dimensions of output images when converting a PDF? You can customize the height and width of the output images by specifying the maximum dimensions while maintaining the aspect ratio of the original document. What should I do if I want form fields to be visible in the output images? To make form fields visible in the output images, flatten the PDF before converting it to an image or pass true to the Flatten parameter of the method. Can I save a PDF as a single multi-page TIFF file using a software library? Yes, IronPDF provides a method called ToMultiPageTiffImage, which renders the PDF pages as a single multi-page TIFF file and saves it to disk. Does any library allow converting a PDF to an SVG format? Yes, IronPDF offers methods like SaveAsSvg and ToSvgString to convert a PDF document to an SVG format. Chaknith Bin Chat with engineering team now Software Engineer Chaknith is the Sherlock Holmes of developers. It first occurred to him he might have a future in software engineering, when he was doing code challenges for fun. His focus is on IronXL and IronBarcode, but he takes pride in helping customers with every product. Chaknith leverages his knowledge from talking directly with customers, to help further improve the products themselves. His anecdotal feedback goes beyond Jira tickets and supports product development, documentation and marketing, to improve customer’s overall experience.When he isn’t in the office, he can be found learning about machine learning, coding and hiking. Ready to Get Started? Free NuGet Download Total downloads: 14,143,061 View Licenses