Docotic.Pdf Library Help > Samples > Draw and print PDF > Save PDF page as image with specified resolution

This sample shows how to save a PDF page as image with specified resolution.

Use PdfDrawOptions.HorizontalResolution and PdfDrawOptions.VerticalResolution properties to set desired resolution (in pixels per inch) for output image. Then use configured PdfDrawOptions as parameter for PdfPage.Save() method.

Saving of PDF as image is not supported in version for .NET Standard.

C#
using System.Diagnostics;

using BitMiracle.Docotic.Pdf;

namespace BitMiracle.Docotic.Pdf.Samples
{
    public static class SavePageCustomResolution
    {
        public static void Main()
        {
            // NOTE: 
            // When used in trial mode, the library imposes some restrictions.
            // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            // for more information.

            string pathToImage = "SavePageCustomResolution.png";

            using (PdfDocument pdf = new PdfDocument(@"Sample Data\gmail-cheat-sheet.pdf"))
            {
                PdfDrawOptions options = PdfDrawOptions.Create();
                options.BackgroundColor = new PdfRgbColor(255, 255, 255);
                options.HorizontalResolution = 600;
                options.VerticalResolution = 600;

                pdf.Pages[0].Save(pathToImage, options);
            }

            Process.Start(pathToImage);
        }
    }
}
VB
Imports System.Diagnostics

Imports BitMiracle.Docotic.Pdf

Namespace BitMiracle.Docotic.Pdf.Samples
    Public NotInheritable Class SavePageCustomResolution
        Public Shared Sub Main()
            ' NOTE: 
            ' When used in trial mode, the library imposes some restrictions.
            ' Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            ' for more information.

            Dim pathToImage As String = "SavePageCustomResolution.png"

            Using pdf As New PdfDocument("Sample Data\gmail-cheat-sheet.pdf")
                Dim options As PdfDrawOptions = PdfDrawOptions.Create()
                options.BackgroundColor = New PdfRgbColor(255, 255, 255)
                options.HorizontalResolution = 600
                options.VerticalResolution = 600

                pdf.Pages(0).Save(pathToImage, options)
            End Using

            Process.Start(pathToImage)
        End Sub
    End Class
End Namespace