There are 2 most common reasons that you may obtain an output PDF that is bigger than the original PDF after optimization.
Object Compression
In a PDF document, the reference table – which is the table that indicates where each objects is located in the file – can be compressed as what is known as a cross reference stream. See PDF Specifications “3.4.7 Cross-Reference Streams”.
Update: This issue is resolved as of v2017R1. We’ve added an option to re-compress the reference table and object streams. Make sure to use the optimization settings below to resolve this issue:
OptSettings.setCompressObjectsIntoStreams(true); |
For this type of documents, Qoppa’s optimizing library jPDFOptimizer is able to read the reference table appropriately but is not, at the moment, able to re-compress the object stream upon saving the document. And so it is possible that the output ‘compressed’ PDF is a bit larger than the original original (if it also happens that other compression functions were negligible in size).
We’re planning to support re-compressing the reference table soon. If you are running into this issue, email us so we can keep track of how often this issue occurs and prioritize this fix accordingly.
Image Compression
Sometime when re-compressing images, you may obtain bigger images in the output PDF than in the original file.
In a future version of the jPDFOptimizer library, we will add a setting allowing to preserve the original image if the re-compressed image is bigger than the original. This will help customers whose priority is to reduce the file size rather than to change the actual image compression / properties.
Until we add this setting, here are possible workarounds to avoid a bigger image output size:
- jPDFOptimizer API is very flexible and lets customers set compression options at the image level, choosing to ignore specific images. When compressing JPEG or JPEG2000 images, it is important to carefully review the quality parameter.
- Customers can compare the output document size to the original document size and keep the original document if the output document is bigger. Size information is available in the optimizer report.