I’m trying to get image size and dimension of the attached pdfs. When an image is 150% or higher form the original size I would like to reject the file.
I found an example in your docs “Getting Image Information without Extracting the Images”:
But unfortunately I never reach the part where ScaledWidth and OriginalWidth is calculated.
I’ve adjusted the example so it will iterate through all pages and all contents:
Code snippet:
//Iterate through all the pages
foreach (Page page in doc.Pages)
{
...
// Get all the operators on first page of document
foreach (Operator op in page.Contents)
{
Thanks for using our products and sorry for the delayed response.
I have tested the scenario using Aspose.Pdf for .NET 8.1.0 using following code snippet and as per my observations, the image dimensions and related information is properly being retrieved. Can you please share which version of product you are using. We are sorry for this inconvenience.
[C#]
// Load the source PDF document<o:p></o:p>
Aspose.Pdf.Document
doc = new Aspose.Pdf.Document("c:\\pdftest\\Hybride2.pdf");
Thank you for your reply. I've used Aspose Pdf for .NET 8.0.0 and retested with 8.1.0 but the results were the same. However after applying a (30day demo) license file I could use the ImagePlacementAbsorber which returned an ImagePlacementCollection with all the properties.
Thank you for your example, now I could easily use image resolution and scaling to decide if image has a minimum quality. Problem solved!
I am glad to hear that your problem is resolved while using the license file. Furthermore I would like to share that recently we have published a new version of Aspose.Pdf for .NET 8.2.0. You may consider upgrading to the latest release.
In the event of any further query, please feel free to contact.