We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

No Images in Document.Pages[].Resources.Images

Hello,


I have a Document where i want to compress the embedded images.
The Problem is: I can’t find them. If I iterate through the Pages, the Resources.Images-collections are allways empty.
Is there another way for accessing and replacing images?

An example PDF is attached. It has two pages with images.
The used Version of Aspose.PDF is 9.6.0.0 (2014.09.01).

Greetings
Benjamin


Hi Benjamin,


Thanks for contacting support.

I have seen the PDF document which you have shared in your earlier post and the reasons Document.Pages[].Resources.Images is always returned as empty is because images are not added as resources but they are added as background artifact.

Aspose.Pdf for .NET supports the feature to compress/optimize the PDF file size but I am afraid this feature is not optimizing PDF file size, when using with images.pdf. For the sake of correction, I have logged this problem as PDFNEWNET-39705 in our issue tracking system. We will further look into the details of this problem and will keep you posted with our findings. We are sorry for this inconvenience.

[C#]

//
Load the source PDF file
<o:p></o:p>

Document doc = new Document("c:/pdftest/images.pdf");

doc.OptimizeResources(new Document.OptimizationOptions()

{

CompressImages = true,

ImageQuality = 100,

RemoveUnusedObjects = true,

LinkDuplcateStreams = true,

AllowReusePageContent = true,

RemoveUnusedStreams = true

});

doc.Save("c:/pdftest/OptimizedFile.pdf");

Hello Nayyer,


thank for your answer. The automatic optimisation is nice to have - i need to change the resolution of the image itself. The images are often directly imported from a camera with many megapixels.

Can I access the background artifacts to change them?

By the way: the PDFs are generated from a docx with Aspose.Words.

Greetings
Benjamin

Hi Benjamin,


Thanks for sharing the feedback.

As shared in my earlier post, the API is causing issue while optimizing PDF file size which is comprised of images added as background. The product team will further look into the details of this problem and see how we can optimize our algorithm compress size of such documents. As soon as we have some definite updates, we will let you know.

Meanwhile I have intimated Aspose.Words team to look into this scenario and share any option/method which can optimize PDF file size, when transforming Word document to PDF format. Soon you will be updated with required information.

Hi Benjamin,


Thanks for your inquiry. I believe you can meet this requirement using PdfSaveOptions.DownsampleOptions property of Aspose.Words. Here is description of possible settings:

DownsampleImages

Specifies whether images should be downsampled.

Resolution

Specifies the resolution in pixels per inch which the images should be downsampled to.

ResolutionThreshold

Specifies the threshold resolution in pixels per inch. If resolution of an image in the document is less than threshold value, the downsampling algorithm will not be applied. A value of 0 means the threshold check is not used and all images that can be reduced in size are downsampled.


Hope, this helps. In case the problem still remains with latest version of Aspose.Words for .NET 15.10.0, please attach your input Word document here for testing. We will investigate the issue on our end and provide you more information.

Best regards,