[JAVA]Request for instructions on converting pages to 120ppi and compression at the same time

I am facing some difficulties to down scale all the pages in the pdf to 120ppi. All of the pages inside the pdf are scanned images,1 scanned image per page. At the same time, I would also like to compress the pdf. However with all the resources provided, the pdf size become larger than original.

I’ve used the following guide to assist me for changing of resolution and also compression:
-https://docs.aspose.com/pdf/java/setting-dpi-or-ppi-of-images-in-pdf/

@PleaseHelpSam

Could you please also share the sample PDF document for our reference so that we can test the scenario in our environment and address it accordingly.

@asad.ali

Thank for the swift response.
Due to the confidential content in the pdf file we do not have the sample of the file.
However, I am able to proof there is a spike in size after compression was made.

The top was the before compression, the bottom was after being compressed.

proof.png (50.5 KB)

Following was my code used for the compression

|||OptimizationOptions opt = new OptimizationOptions();|
|---|---|---|
|||opt.setRemoveUnusedObjects(true);|
|||opt.setLinkDuplcateStreams(true);|
|||opt.setRemoveUnusedStreams(true);|
|||opt.setAllowReusePageContent(true);|
|||opt.getImageCompressionOptions().setResizeImages(true);|
|||opt.getImageCompressionOptions().setMaxResolution(maxResolution);| // 120
|||opt.getImageCompressionOptions().setCompressImages(true);|
|||opt.getImageCompressionOptions().setImageQuality(imageQuality);| //10
|||doc.optimizeResources(opt);|

@PleaseHelpSam

Sometimes, issues are related to specific PDF documents and they are resolved for those particular PDF files. In order to address such issues, we need a sample PDF document so that we can investigate the reasons behind them. It is requested that you please share a sample PDF. If you cannot share it publicly, you can share it in private message by clicking over username and pressing the Blue Message Button.

As spoken, attached is the sample file _PleaseHelpSam_Sample.pdf (2.1 MB)

@PleaseHelpSam

We were able to replicate the issue at our end using Aspose.PDF for Java 21.5. We noticed that the size of output was bigger than the input. Therefore, an issue has been logged as PDFJAVA-40587 in our issue tracking system. We will further look into its details and keep you posted with the status of its rectification. Please be patient and spare us some time.

We are sorry for the inconvenience.

Thanks for helping to logged. May I know how long does it takes for the rectification?

@PleaseHelpSam

The issue has recently been logged in our issue tracking system and it is pending for an analysis. It will be investigated and resolved on a first come first serve basis as per free support policies. We will surely inform you once we have some news about its investigation or fix ETA. Please give us some time.