Take a look at the below java code and customize it accordingly in java action
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.
If your PDF contains images, you can try the solution below. It reduces the resolution of an image and converts it to a JPG.