Exception while PDF Compression

Getting NullPointerException while using optimizeResources of aspose pdf in java.
How to resolve

@Kavya1812

Would you please share your sample PDF along with the sample code snippet so that we can test the scenario in our environment and address it accordingly?