We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Returning the dpi of a pdf-document

Hi,

can you provide me an example of getting the dpi and/(or some qualitiy measurement) of an pdf ?

thanks

7 Replies

SK Surya Kumar Syncfusion Team February 20, 2017 12:58 PM UTC

Hi Syress, 
 
We appreciate your interest towards Syncfusion products. 
 
Since a PDF is a vector document we cannot measure DPI or resolution of PDF. However, we can measure resolution of the images present in the PDF document with the help of below code snippet. 
 
            PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf"); 
            List<float> horizontalResolution = new List<float>(); 
            List<float> verticalResolution = new List<float>(); 
 
            foreach (PdfPageBase page in loadedDocument.Pages) 
            { 
 
                //Extracts the images from the document 
                Image[] extractedImages = page.ExtractImages(); 
                 
 
 
                //Iterates all the image 
                for (int j = 0; j < extractedImages.Length; j++) 
                { 
 
                    PdfImage img = new PdfBitmap(extractedImages[j]); 
                    horizontalResolution.Add(img.HorizontalResolution); 
                    verticalResolution.Add(img.VerticalResolution); 
 
                } 
 
 
            } 
 
 
Please let us know if you need any further information regarding this. 
 
Regards, 
Surya Kumar. 



SS Syress Sumartha February 27, 2017 11:36 AM UTC

Hi, I don't need the images extracted, I need something where I can see the qualitity of an pdf, after it has been scanned by a scanner.(does it make sense to convert every page to an image and than see the resolution ?!) Please provide me an example.


SK Surya Kumar Syncfusion Team February 28, 2017 11:09 AM UTC

Hi Syress, 
Thanks for your update. 
Quality of a scanned PDF cannot be measured since its elements like text and vector graphics are tends to vary depending on the output device from which it is generated and there is no quantity to measure those elements. 
However, if the scanned PDF is containing image elements then its quality can be measured which we have mentioned in previous update. 
Please let us know if you need any further information. 
Regards, 
Surya Kumar 



PE Peter March 8, 2017 07:15 AM UTC

Is there no way to get the quality, even if converting a pdf to an image to see its resolution and convert it back to pdf afterwards ? Do it make sense ?


PH Praveenkumar H Syncfusion Team March 9, 2017 12:24 PM UTC

Hi Peter, 

As we said earlier in this forum, Quality of a scanned PDF cannot be measured since its elements like text and vector graphics are tends to vary depending on the output device from which it is generated and there is no quantity to measure those elements.  
 
You can check this by using the below code. 
 
PdfLoadedDocument document = new PdfLoadedDocument("../../Data/sample.pdf"); 
//exporting first page of the PDF to image with 96 DPI 
Bitmap bitmap=document.ExportAsImage(0,96,96); 
bitmap.Save("sample.jpg"); 
System.Diagnostics.Process.Start("sample.jpg"); 
 
Here the exported image quality depends on the DPI value, so image quality will get change, depend upon the DPI value, you can check this by changing the DPI value in the method document.ExportAsImage(0,96,96);. 
 
However, if the scanned PDF is containing image elements then its quality can be measured by extracting the image from the PDF document. 
 
Please let us know if you need further assistance. 
 
Regards, 
Praveen 



HK Haikal Khair August 8, 2018 03:06 PM UTC

Is there a maximum Value, which can be chosen for DPI, and is there a documentation of the classes and their methods?


KC Karthikeyan Chandrasekar Syncfusion Team August 9, 2018 06:03 AM UTC

Hi Haikal, 
We hadn’t set any limit to provide DPI to the images exported. So there is no maximum DPI value. You can get the class reference details from the below link. 

Note: We are facing some issue in the class reference documentation, we will analyze in this and refresh it. 
Regards, 
Karthikeyan 


Loader.
Live Chat Icon For mobile
Up arrow icon