PDFRasterizer.NET 4.0 is now available. Supports .NET Core. Renders pixel-perfectly.

Render PDF page to Skia surface

Starting with version 4.0, we use the Skia 2D graphics library to render PDF pages. Methods Page.Saveand Document.ConvertToTiff can be used to render pages or documents directly to single- or multipage raster images. It is however also possible to render to a Skia surface. This is demonstrated by the following code sample.

Open PDF and select the first page

var pdf = new Document(stream);
var page = pdf.Pages[0];

Calculate the size of the image

const float scale = 1.0f; // 72 dpi
var pageBox = page.CropBox ?? page.MediaBox;
int width = (int)Math.Round(pageBox.Width * scale);
int height = (int)Math.Round(pageBox.Height * scale);
if (page.Rotation % 180 != 0)
  int tmp = width;
  width = height;
  height = tmp;

Render page into Skia surface

var info = new SKImageInfo(width, height);
using (var surface = SKSurface.Create(info))
  page.Draw(surface, info, scale);
  // ...

Save rendering buffer to raster image

using (var pixmap = surface.PeekPixels())
using (var imagegStream = new SKFileWStream(file))
  pixmap.Encode(imageStream, SKEncodedImageFormat.Jpeg, 90);
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.