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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Returning the dpi of a pdf-document

Thread ID:

Created:

Updated:

Platform:

Replies:

128954 Feb 17,2017 01:33 PM UTC Aug 9,2018 06:03 AM UTC ASP.NET MVC 7
loading
Tags: PDF
Syress Sumartha
Asked On February 17, 2017 01:33 PM UTC

Hi,

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

thanks

Surya Kumar [Syncfusion]
Replied On 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. 


Syress Sumartha
Replied On 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.

Surya Kumar [Syncfusion]
Replied On 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 


Peter
Replied On 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 ?

Praveenkumar H [Syncfusion]
Replied On 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 


Haikal Khair
Replied On 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?

KarthikeyanC [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;