Hi,
Take a look at the below java code and customize it accordingly in java action
https://stackoverflow.com/questions/14354712/how-to-reduce-pdf-file-size-programmatically-in-java
Hope it helps!!!
It maybe the PDF can’t be shrunk more. If the objective is to reduce storage size, another option could be to try zipping the file before sending it to the user. If this is acceptable, take a look at the Zip Handling module in the marketplace and see if that can give you the file size reduction you need.
https://marketplace.mendix.com/link/component/108292
Good luck!
If your PDF contains images, you can try the solution below. It reduces the resolution of an image and converts it to a JPG.
https://stackoverflow.com/questions/20614350/compress-pdf-with-large-images-via-java