PDF Compression increasing document size and killing some images

Hi Aspose team,



in case of some PDF documents that I wanted to compress Aspose components are increasing size of “compressed” document and also in some cases destroying images.



Over attached project you can make test.

Attached documents:

- doc.pdf, size 1678518 bytes

- doc_compressed.pdf, size 3416593 (image in header of this document is destroyed)



- paypal_subscription.pdf, size 552973

- paypal_subscription_compressed.pdf, size: 965317



When I tried to compress same files over smallpdf.com I got following results:



- paypal_subscription.pdf was reduced to 279.9KB

- doc.pdf was reduced to 1.39Mb



Can you assist?



P.S. Documents are in bin/debug folder.



Thanks,

Oliver

Hi Oliver,


Thanks for your inquiry. Please note use following code for compression it also compress images, so no need to use XImage and Replace method for images.

paypal_subscription_compressed.pdf 503 KB
doc_compressed.pdf 1435 KB



Document pdfDocument = new Aspose.Pdf.Document(myDir

  • “paypal_subscription.pdf”);<o:p></o:p>

pdfDocument.OptimizeResources(new Document.OptimizationOptions()

{

LinkDuplcateStreams = true,

RemoveUnusedObjects = true,

RemoveUnusedStreams = true,

CompressImages = true,

ImageQuality = 50,

UnembedFonts = false,

AllowReusePageContent = true

});

pdfDocument.Save(myDir + "paypal_subscription_compressed.pdf");

Please feel free to contact us for any further assistance.

Best Regards,

Thanks for reply, worked for images :slight_smile:
Second question is what are plans to improve compressions?

If you check paypal_subscription document Aspose managed to compress it to 504kb and one of free online tools reduced document size mich better.

Quality of both documents is similar (good).

Thanks,
Oliver

Hi Oliver,


Thanks for your inquiry. In reference to your another post, we have already logged a ticket PDFNEWNET-38850 to investigate the compression issue. So we linked your current post to the issue id. Our product team will investigate it and guide you accordingly.

We are sorry for the inconvenience caused.

Best Regards,

Hi Oliver,


Thanks for your patience. Our product team has investigated the issue and enhanced optimization feature by adding two new properties in OptimizationOptions object, ResizeImages and MaxResolution. These properties will be available in upcoming release of Aspose.Pdf for .NET i.e. 16.12.0. Hopefully it will be released in couple of days. However, we will notify you as soon as new release is published and gets available for download. With new release, you can optimize PDF documents as following:

Aspose.Pdf.Document
document = new Aspose.Pdf.Document(“38850.pdf”);<o:p></o:p>

// Optimzie the file size by removing
unused objects
<o:p></o:p>

document.OptimizeResources(new
Aspose.Pdf.Document.OptimizationOptions()<o:p></o:p>

{<o:p></o:p>


LinkDuplcateStreams = true,<o:p></o:p>

RemoveUnusedObjects
= true,<o:p></o:p>


RemoveUnusedStreams = true,<o:p></o:p>


AllowReusePageContent = true,<o:p></o:p>


UnembedFonts = true,<o:p></o:p>


CompressImages = true,<o:p></o:p>


ResizeImages = true,<o:p></o:p>


MaxResoultion = 150,<o:p></o:p>


ImageQuality = 10<o:p></o:p>

});<o:p></o:p>

// Save the updated file<o:p></o:p>

document.Save(“38850-out.pdf”);<o:p></o:p>


Best Regards,

The issues you have found earlier (filed as PDFNEWNET-38850) have been fixed in Aspose.Pdf for .NET 16.12.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
(1)