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

Convert PDF with layers to image

In the code sample below you see how you can incorporate multiple layers into your rendering process. Simply set the Visibility of the layers which you want to render to true, and add the LayerCollection to your RenderSettings object.

using (FileStream fs = new FileStream(@"..\..\input.pdf", FileMode.Open, FileAccess.Read))
{
    Document d = new Document(fs);
    LayerCollection layers = d.Layers;

    //select layers to render
    layers[0].Visible = true;
    layers[1].Visible = false;

    Page page = d.Pages[0];

    Bitmap bitmap = new Bitmap((int)page.Width, (int)page.Height);
    using (Graphics graphics = Graphics.FromImage(bitmap))
    {
        RenderSettings renderSettings = new RenderSettings();
        renderSettings.LayerSettings.Layers = layers;
        graphics.SmoothingMode = SmoothingMode.AntiAlias;
        page.Draw(graphics, renderSettings);
    }
    bitmap.Save(@"..\..\output.bmp");
}
Download PDFRasterizer.NET 3.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.