Aspose size reduction in eval?

I am testing out Aspose PDF Java to see if it can reduce the size of PDFs. I see the sample code and have used all the optimizationOptions.
I am not seeing the size reduction I was expecting compared to similar PDF libraries (but Aspose is a preferred vendor) so wondering if the eval only converts a few objects/images and then stops.
Can anyone confirm?
I am guessing it won’t look at more than 4 pages since that is all pdfDocument.getPages() will return without error.

If it is crippled - is there anyway I can test out one PDF to see how real compression will work on the paid product?
thanks

@larbster

Yes, you can obtain a free 30-days temporary license in order to evaluate the API in its full capacity without any restrictions. In case you still notice any issues, please share your sample PDF with us and we will test the case to address it accordingly.

Thanks very much.
Got the license, but didn’t help much with size reduction. If possible, can you try to see if you can reduce this to say 15MB? I can’t get it below 23MB.
you can grab the PDF from here (scientific publishing site - we are a customer [aspose.words])
https://opg.optica.org/aop/fulltext.cfm?uri=aop-12-4-847&id=444113
or if you prefer I can upload the 28MB PDF
Best regards

@itreg

Can you please also share the complete code snippet that you used for optimizing the PDF? We also noticed that the API was not able to reduce the size much. However, we prefer to log an issue with the same code snippet that you tried.

Sure. I pretty much tried everything on this page - Optimize, Compress or Reduce PDF Size in Java|Aspose.PDF for Java
In addition to the below, I also tried the flate image compression instead of the setCompressImages() and setImageQuality() method calls.

package com.aspose.pdf.examples;

import java.io.FileNotFoundException;
import java.time.Clock;
import java.time.Duration;

import com.aspose.pdf.*;
import com.aspose.pdf.optimization.ImageCompressionVersion;
import com.aspose.pdf.optimization.ImageEncoding;

public class ExampleOptimize {

    private static String _dataDir = "/home/admin1/pdf-examples/Samples/";

    public static void OptimizePDFDocumentForTheWeb() {

        // Open document
        Document pdfDocument = new Document(_dataDir + "sample.pdf");
		
		// Removing or Flattening Annotations
		for (Page page : pdfDocument.getPages()) {
            for (Annotation annotation : page.getAnnotations())
                annotation.flatten();
        }


        // Initialize OptimizationOptions
        com.aspose.pdf.optimization.OptimizationOptions optimizationOptions = new com.aspose.pdf.optimization.OptimizationOptions();

        // Set CompressImages option
        optimizationOptions.getImageCompressionOptions().setCompressImages(true);

        // Set ImageQuality option
        optimizationOptions.getImageCompressionOptions().setImageQuality(25);
		
		optimizationOptions.setRemoveUnusedObjects(true);   
		optimizationOptions.setRemoveUnusedStreams(true);		

        // Optimize PDF document using OptimizationOptions
        pdfDocument.optimizeResources(optimizationOptions);

        // Save output document
        pdfDocument.save(_dataDir + "OptimizeDocument_out.pdf");
    }
}

@larbster

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFJAVA-43544

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@larbster

You can use one additional optimization parameter options.setRemovePrivateInfo(true) and get the necessary result.

The output file size is 6.67 Mb.

Full code snippet:

Document pdfDocument = new Document(_dataDir + "aop-12-4-847.pdf");

com.aspose.pdf.optimization.OptimizationOptions optimizationOptions = new com.aspose.pdf.optimization.OptimizationOptions();
optimizationOptions.getImageCompressionOptions().setCompressImages(true);
optimizationOptions.getImageCompressionOptions().setImageQuality(25);
optimizationOptions.setRemoveUnusedObjects(true);
optimizationOptions.setRemoveUnusedStreams(true);
optimizationOptions.setRemovePrivateInfo(true);

pdfDocument.optimizeResources(optimizationOptions);

pdfDocument.save(_dataDir + "43544_out.pdf");

43544_out.pdf (6.7 MB)