Drawing PDF Page to Screen (WinForms)

Posted by: AnthonyC on 9 March 2021, 6:36 am EST

  • Posted 9 March 2021, 6:36 am EST

    Hello,

    I'm developing an application that can display documents in several different formats (i.e., Tiff, Jpeg, Pdf). Currently, I'm using the GcPdfDocument library to load the Pdf documents. To display them, I'm grabbing a Page from the document and calling the SaveAsJpeg method to save the image to a MemoryStream. From that stream, I am creating an image to draw to the screen with a Windows Forms Graphics object. In addition to the main page view, I am also generating thumbnails from each page, following the same process.

    In both instances, I'm calling the SaveAsJpeg method with a SaveAsImageOptions object passed in. The only difference is that for the thumbnails, I'm using the default resolution of 96 and for the main image, I'm using a resolution of 300. The thumbnails are being generated fairly quickly, however the main image is taking a couple seconds to render because of the resolution. I am caching the rendered image so that it doesn't take long the next time it is called to be viewed, but the initial time it is called is taking too long.

    My question, is there any way to do what I am doing differently? Or is there any way to increase the quality of the image without sacrificing rendering speed? And lastly, are there any sample projects I can look at that will help with what I am trying to accomplish?

    Let me know if you need me to explain anything in more detail or if there is anything else you need.

    Thank you!

    - Anthony
  • Marked as Answer

    Replied 11 March 2021, 12:15 am EST

    Hello Anthony,

    I too can observe the performance issue when saving the image with high resolution.
    I have verified it in the attached sample. I would request you to modify the sample as per your requirement so that we can further discuss it with the developers.

    Regards,
    Prabhat Sharma.
    gcpdf_Image.zip
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels