We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.PDF invoke OptimizeResources method throw error

I have a pdf file,I want to optimize it by Aspose.PDF,But thow a NullReferenceException when i invoke OptimizeResources method.
please tell me how to do? I am try to invoke Repair() method to repair the pdf file ,but it not work!
the version is Aspose.PDF for .Net 20.12.0.0.

the sample code :

string inputFile = @"C:\Users\sullivan\Desktop\6下第5单元详细考点梳理.pdf";
string outputFIle = @"C:\Users\sullivan\Desktop\result.pdf";
var pdfDocument = new Aspose.Pdf.Document(inputFile);
var optimizeOptions = new Aspose.Pdf.Optimization.OptimizationOptions();
optimizeOptions.ImageCompressionOptions.CompressImages = true;
optimizeOptions.ImageCompressionOptions.ImageQuality = 70;
optimizeOptions.ImageCompressionOptions.Version = Aspose.Pdf.Optimization.ImageCompressionVersion.Fast;
pdfDocument.OptimizeResources(optimizeOptions);
pdfDocument.Save(outputFIle);

the sample file:
6下第5单元详细考点梳理.pdf (405.8 KB)

thank you!

@sullivan

We have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as PDFNET-51128. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as PDFNET-51128) have been fixed in Aspose.PDF for .NET 22.3.