Free Support Forum - aspose.com

Get best quality png file from pdf

Hi. I am converting PDF to PNG through the code below;

 using (Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(file))
                {
                    Aspose.Pdf.PageCollection pageCollection = pdfDocument.Pages;
                    Aspose.Pdf.Page pdfPage = pageCollection[selectedPage];
                    using (MemoryStream imageStream = new MemoryStream())
                    {
                        Resolution resolution = new Resolution(**quality**);
                        PngDevice pngDevice = new PngDevice(resolution);
                        pngDevice.Process(pdfPage, imageStream);

                        using (Bitmap img = new Bitmap(imageStream))
                        {  
                            img.Save(output);
                        }

The problem is the higher ‘quality’ doesn’t guarantee better image quality.
For example, depending on the PDF file, ‘quality’ 386 image output quality could be better
than ‘quality’ 1800 image output.

Is there are any way to find the ‘quality’ value for the best image output quality?

@yjyj1990

Could you please share your sample PDF document as well so that we can test the scenario in our environment and share our feedback accordingly.

You can download the sample pdf from this link https://www.certificatelab.org/certificates-of-death/download-free-death-certificate-pdf-sample
(Sorry about the contents… but mear website I can approach from my work computer.)
When you convert 1st page with quality value 386, png size is 5169.
for quality value 3333, png size is 5907.
for quality value 1200, png size is 10963.

My goal is to get the best quality png file out of the pdf.
Thank you.

@yjyj1990

We need to further investigate this requirement as a PDF document does not have any resolution and it renders depending upon the device where you are viewing it. However, we will further analyze whether it is possible to improve output image quality or not and let you know as soon as the logged ticket PDFNET-49178 is resolved. Please be patient and spare us some time.

Hi, I was wondering if there is any update.
Thank you.

@yjyj1990

Regretfully, the issue is not yet resolved due to other pending issues in the queue which were logged prior to it. However, we will inform you as soon as we have some update regarding ticket resolution. Please be patient and give us some time.

We apologize for the inconvenience.