Render PDF page as PNG

The following code renders the first page of a PDF document as a PNG at 150 DPI:

using (var pdfFile = new FileStream(pdfPath, FileMode.Open, FileAccess.Read))
using (var imageFile = new FileStream(imagePath, FileMode.Create))
{
  var pdf = new Document(pdfFile);
  var page = pdf.Pages[0];
  float resolution = 150f; // 150 DPI
  page.SaveAsBitmap(imageFile, ImageEncoding.Png, resolution);
}

Image formats

The following image formats are supported:

  • ImageEncoding.Png
  • ImageEncoding.Jpeg
Download PDFRasterizer.NET 4.0
We will send you a download link
  • This field is for validation purposes and should be left unchanged.
Why do we ask your email address?
We send tips that speed up your evaluation
We let you know about bug fixes
You can always unsubscribe with one click
We never share your address with a 3rd party
Thank you for your download

We have sent an email with a download link.