Spire.PDFViewer is a powerful PDF Viewer component for .NET. It allows developers to load PDF document from stream, file and byte array.

Sat Mar 12, 2022 10:52 pm

I am using the PdfDocumentViewer.SaveAsImage(int pageIndex) method. The images it creates are very low resolution. How to I configure the desired resolution? Zooming the page in the viewer does not change the size of the image created.

Also, does it always create at Bitmap class of image? If so, it would be helpful if the function was defined to return that instead of Image. If not, how to we tell SaveAsImage which class to use?

Thank you!

MikePelley
 
Posts: 1
Joined: Sat Mar 12, 2022 10:44 pm

Mon Mar 14, 2022 6:06 am

Hello,

Thank you for your inquiry.
Please note that Spire.PDFViewer is only used for viewing the PDF file, and Spire.PDF is used for specific operations on the PDF file. Please refer to the following code to set the resolution of the image.
Code: Select all
...
dialog.Filter = "PDF document (*.pdf)|*.pdf";
DialogResult result = dialog.ShowDialog();
string fileName = dialog.FileName;

if (result == DialogResult.OK)
{
    try
    {
        document = new PdfDocument();
        document.LoadFromFile(fileName);
        for (int i = 0; i < document.Pages.Count; i++)
        {
            //Set the image type and resolution
            Image image = document.SaveAsImage(i, Spire.Pdf.Graphics.PdfImageType.Bitmap, 300, 300);
        }

    }
    catch (IOException)
    {
        document = null;
    }
...
}

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1650
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.PDFViewer