When converting from PDF to PDF/A, the document grows a lot

The convert() method complains about compressed images. However, our customer has a PDF tool (PDF-XChange Editor) that keeps the document size. Sometimes the size factor is up to 10.

I’ve tried the optimize function, no improvement.
Is there only a way out, to reduce the resolution?

A sample PDF and result is attached (original 3mb, pdf/a 7mb).

Here is the Code:
public static void main( String[] args ) throws Exception {

    new License().setLicense( "Aspose.Total.Java.lic" );
    
    String infile = "test-shading.pdf";
    String outfile = "test-shading-pdf2a.pdf";        
    
    System.out.println( "file size: " + Files.size( Path.of( infile ) ) );
    Document doc = new Document( infile );

    OptimizationOptions opt = new OptimizationOptions();
    opt.getImageCompressionOptions().setCompressImages( true );
    doc.optimizeResources(opt);
    
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    boolean ok = doc.convert( baos, PdfFormat.PDF_A_2A, ConvertErrorAction.Delete );

    if ( baos.size() > 0 ) {
        String warn = baos.toString( StandardCharsets.UTF_8 );
        System.out.println( warn );
    }
    
    if ( !ok ) {            
        System.out.println( "error convert" );
        System.exit( 1 );        
    }

    doc.optimizeResources();
    doc.save( outfile );
    System.out.println( "outfile size: " + Files.size( Path.of( outfile ) ) );
}

test-shading.zip (1.9 MB)

@depi

We suggest you please use following code example. Hope this helps you.

Document doc = new Document( MyDir + "Test Schattierung.pdf" );

//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(75);

// Set ResizeImage option
optimizationOptions.getImageCompressionOptions().setResizeImages(true);

// Set MaxResolution option
optimizationOptions.getImageCompressionOptions().setMaxResolution(300);

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

doc.save( MyDir + "21.12.pdf" );

Moreover, please read the following article about optimizing PDF file.
Optimize PDF Document

I’ve tried everything. If you omit the conversion to PDF/A and only improve the document via optimize()/optimizeResources, the document will always be a bit larger.

The source document is already highly optimized.
The question now is why converting to PDF/A makes it so much larger.

@depi

We have logged this problem in our issue tracking system as PDFJAVA-41231. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.