Examples

Convert PDF to Image

Use DynamicPDF Rasterizer for .NET to efficiently and easily convert any PDF to a variety of image formats. It supports rasterizing PDFs to common image formats and offers a robust set of images and quality settings.

DynamicPDF Rasterizer supports the following image types.

  • JPG/JPEG
  • PNG
  • TIFF, Multipage TIFF
  • GIF
  • BMP

Watch the Video

Converting a PDF to an Image

Follow these steps and sample code example to convert a PDF file to multiple image formats.

Steps

  1. Create a PdfRasterizer object instance using the source PDF document.
  2. Call the Draw method by specifying the file path to save the image, the image type as jpeg, and the image size as Dpi72.
  3. Repeat step two, but change the file type to png and Dpi300.
  4. Repeat step two, but change the file type to tiff and Dpi300.

Sample code - C# (PDF to JPG)

PdfRasterizer rasterizer = new PdfRasterizer("doc-a.pdf");
rasterizer.Draw("output.jpg", ImageFormat.Jpeg, ImageSize.Dpi72);

Sample code - C# (PDF to PNG)

PdfRasterizer rasterizer = new PdfRasterizer("doc-a.pdf");
rasterizer.Draw("output.png", ImageFormat.Png, ImageSize.Dpi300);

Sample code - C# (PDF to TIFF)

PdfRasterizer rasterizer = new PdfRasterizer("doc-a.pdf");
rasterizer.Draw("output.png", ImageFormat.Png, ImageSize.Dpi300);

Converting a PDF to multi-page TIFF

Create a multipage TIFF from a PDF by using the PdfRasterizer class's DrawToMultiPageTiff method. DynamicPDF Rasterizer has the following tiff image formats available for PDF to TIFF image conversion.

  • ImageFormat.TiffWithLzw
  • ImageFormat.TiffWithCcitGroup4
  • ImageFormat.TiffWithCcitGroup3

Steps

  1. Create a PdfRasterizer object instance using the source PDF document.
  2. Call the DrawToMultiPageTiff method by specifying the file path to save the image, the image type as TiffWithCcitGroup4, and the image size as Dpi150.
  3. Repeat step two, but change the type to gif.
  4. Repeat step two, but change the type to bmp.

Sample code - C# (Multi-page TIFF from PDF)

PdfRasterizer rasterizer = new PdfRasterizer("doc-a.pdf");
rasterizer.DrawToMultiPageTiff("output.tiff", ImageFormat.TiffWithCcitGroup4, ImageSize.Dpi150);

Sample code - C# (PDF to GIF)

PdfRasterizer rasterizer = new PdfRasterizer("doc-a.pdf");
rasterizer.Draw("output.gif", ImageFormat.Gif, ImageSize.Dpi150);

Sample code - C# (PDF to BMP)

PdfRasterizer rasterizer = new PdfRasterizer("doc-a.pdf");
rasterizer.Draw("output.bmp", ImageFormat.Bmp, ImageSize.Dpi96);

GitHub Project

Clone or view the example project at GitHub. This example on this page is in the PdfToImageRasterizerExample.cs file.

Clone or View Example Project on GitHub

Getting Started

The NuGet package and an example project are provided to get started.

NuGet Package

DynamicPDF Rasterizer for .NET is on NuGet with package ID ceTe.DynamicPDF.Rasterizer.NET.

NuGet Package ID: ceTe.DynamicPDF.Rasterizer.NET

DynamicPDF Rasterizer Information

For more information, refer to the online help documentation.

Why Choose DynamicPDF?

  • Transparent Pricing
  • Lots of Features
  • Easy to Use
  • Great Support
  • Efficient Performance
  • Product Maturity (Over 22 Years)
  • Free Evaluation
  • .NET Core Support (Most Products)
  • Flexible Licensing

We’re Not The Only Ones That Think We’re Great!