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

Free Support Forum - aspose.com

PDF file size reduction while in evaluation mode

I’m using Apose.PDF for Java in evaluation to test PDF file size reduction. My PDF is indeed processed by my JAR – I see the watermark text in the processed PDF – but I am not seeing any file size reduction.

I am using these items –

optimizationOptions.setRemoveUnusedObjects(true);
optimizationOptions.setRemoveUnusedStreams(true);
optimizationOptions.setLinkDuplcateStreams(true);
pdfDocument.optimizeResources(optimizationOptions);
pdfDocument.optimize();

Do these work while the product is in evaluation mode? I see either no or very little (20kB) reduction in the file sizes. Using Acrobat Pro can reduce the file size from the original 4MB down to 2MB – is that level of reduction possible with Aspose.PDF?

Thanks!

Jonathan Piasecki

@jonathan.piasecki

The evaluation version of the API processes only 4 elements which is why you are unable to notice significant changes in file size. Please try to use a 30-days free temporary license in order to test the API without any limitation. In case you still notice some issue, please share your sample PDF with us so that we can test the scenario in our environment and address it accordingly.

Thanks for the note – received and installed the evaluation license.

Am seeing some reduction in the file size but not a lot. Test document is 3889 KB and gets reduced to 3695 KB. The document is mostly text – there are only one or two images.

In comparison, both Acrobat DC Pro and Qoppa jPDFOptimizer optimize the file down to 1137 KB.

Am also testing with a 60 MB PDF. Aspose only gets that down to 57 MB. Acrobat and Qoppa get it down to 16 MB, which is what we are looking for.

Can I email you the 4 MB test PDF directly? Would rather not post it to the forum. Let me know where to send it.

Thanks!

Jonathan Piasecki

@jonathan.piasecki

We have sent a private message to you with the instructions to share your files with us privately.

Hello –

By the way, here is the Java code that I am using to try to optimize the PDF. The argument in the new Document(args[0]); is the filename of the PDF created by another process.

Thanks!

Jonathan Piasecki

package asposeoptimizepdf;

import com.aspose.pdf.*;

/**

  • @author PrecisionContent
    /
    public class AsposeOptimizePDF {
    /
    *
  • @param args the command line arguments
  • @throws java.lang.Exception
    */

public static void main(String[] args) throws Exception {

Class cls = Class.forName(“asposeoptimizepdf.AsposeOptimizePDF”);
ClassLoader cLoader = cls.getClassLoader();

License lic = new License();
lic.setLicense(cLoader.getResourceAsStream(“Aspose.PDF.Java.lic”));

Document pdfDocument = new Document(args[0]);

com.aspose.pdf.optimization.OptimizationOptions shrinkageOptions = new com.aspose.pdf.optimization.OptimizationOptions();
shrinkageOptions.setRemoveUnusedObjects(true);
shrinkageOptions.setRemoveUnusedStreams(true);
shrinkageOptions.setAllowReusePageContent(true);
shrinkageOptions.setLinkDuplcateStreams(true);
shrinkageOptions.setUnembedFonts(true);
shrinkageOptions.getImageCompressionOptions().setCompressImages(true);
shrinkageOptions.getImageCompressionOptions().setImageQuality(50);
shrinkageOptions.getImageCompressionOptions().setResizeImages(true);

pdfDocument.optimizeResources(shrinkageOptions);
pdfDocument.optimize();

// Save output document

pdfDocument.save(args[0] + “_Optimized_by_Aspose.pdf”, SaveFormat.Pdf);
}
}

@jonathan.piasecki

We have noticed similar behavior of the API in our environment. The size of PDF file did not get reduced much. Could you please share the sample compressed PDF file that you achieved from Adobe Reader? We will log an investigation ticket in our environment to analysis this case further and share the ID with you.

Hello –

Will send the optimized PDF to the same address I sent the original PDF.

I used Adobe Acrobat DC Pro to optimize the PDF, not just Adobe Reader.

I will also send the PDF as it was optimized by Qoppa jPDFOptimizer (https://www.qoppa.com/pdfoptimizer/).

We really need this level of optimization, and I would really prefer to use Aspose for it.

Thanks – Jonathan Piasecki

@jonathan.piasecki

Thanks for sharing the requested files. We have logged an issue as PDFJAVA-40954 in our issue management system to further look into this case. We will further investigate the scenario in details and let you know as soon as the ticket is resolved. Please be patient and spare us some time.

We are sorry for the inconvenience.

Hello –

Thanks very much for looking into this. I look forward to seeing it work!

Thanks – Jonathan Piasecki