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

Free Support Forum - aspose.com

PDF Optimization throwing exception


I was trying to compress an pdf file
Here is my code:

Document doc = new Document
(new FileInputStream("./data/Example.pdf"));
OptimizationOptions opt = new OptimizationOptions();


And I got an Exception

Exception in thread “main” java.lang.IllegalArgumentException: Map size (0)
must be >= 1
at java.awt.image.IndexColorModel.setRGBs(Unknown Source)
at java.awt.image.IndexColorModel.(Unknown Source)
at com.aspose.pdf.internal.p316.z1.m1(Unknown Source)
at com.aspose.pdf.internal.p316.z1.read(Unknown Source)
at javax.imageio.ImageReader.read(Unknown Source)
at com.aspose.pdf.internal.p279.z1.m1(Unknown Source)
at com.aspose.pdf.internal.p279.z1.m6(Unknown Source)
at com.aspose.pdf.internal.p242.z2.m1(Unknown Source)
at com.aspose.pdf.internal.p242.z2.(Unknown Source)
at com.aspose.pdf.internal.p242.z2.(Unknown Source)
at com.aspose.pdf.internal.p242.z31.m1(Unknown Source)
at com.aspose.pdf.XImageCollection.m1(Unknown Source)
at com.aspose.pdf.ADocument$z4.m1(Unknown Source)
at com.aspose.pdf.ADocument$z4.m1(Unknown Source)
at com.aspose.pdf.ADocument.m1(Unknown Source)
at com.aspose.pdf.ADocument.optimizeResources(Unknown Source)
at com.aspose.pdf.Document.optimizeResources(Unknown Source)
at craig.pdfcompress.test.PDFCompress.main(PDFCompress.java:23)

Aspose PDF version: 9.5.2

Please help me to fix this problem, Thanks :slight_smile:


Thanks for your inquiry. Please share your sample PDF file here, we will look into it and guide you accordingly.

We are sorry for the inconvenience caused.

Best Regards,


I uploaded a pdf file which cause this problem, please check it, thanks :slight_smile:

Hi Craig,

Thanks for sharing the resource file.

have tested the scenario and I am able to reproduce the same problem. For the
sake of correction, I have logged it in our issue tracking system as PDFNEWJAVA-34623. We will
investigate this issue in details and will keep you updated on the status of a
correction. <o:p></o:p>

We apologize for your inconvenience.

The issues you have found earlier (filed as PDFNEWJAVA-34623;PDFNEWJAVA-34623) have been fixed in Aspose.Pdf for Java 10.6.0 .

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