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

Free Support Forum - aspose.com

Exception after Optimize

The following attached file throws an error when trying to save the file after calling optimize. I am using the save with the option of providing a new file name.


System.InvalidOperationException was caught
Message=Failed to compare two elements in the array.
Source=mscorlib
StackTrace:
at System.Array.BinarySearch(Array array, Int32 index, Int32 length, Object value, IComparer comparer)
at System.Collections.ArrayList.BinarySearch(Object value, IComparer comparer)
at .Œ.Contains(Object )
at .œ.( , Boolean )
at ..(Boolean )
at .e.( , , Boolean , Int64& )
at .e.( , )
at .“.( , Int32 )
at .“.( )
at .“.( )
at .“.( , • )
at ..†()
at ..(Stream )
at .€.(Stream )
at Aspose.Pdf.Document.Save(Stream output)
at Aspose.Pdf.Document.Save(String outputFileName)
at Aspire.Framework.PDFFile.SaveChanges() in C:\ApplDev\Aspire.root\Aspire\AspireFramework\File Handling\PDFFile.vb:line 308
InnerException: System.NullReferenceException
Message=Object reference not set to an instance of an object.
Source=Aspose.Pdf
StackTrace:
at ...Compare(Object , Object )
at System.Array.BinarySearch(Array array, Int32 index, Int32 length, Object value, IComparer comparer)
InnerException:

Hi Brent,

Thanks for using our products.

Can you please share some details regarding sample source code you are using or create a sample application to show the issue. This will help us to figure out the issue and reply back to you soon.

We apologize for your inconvenience.

Thanks & Regards,

pdfDoc = New Aspose.Pdf.Document("C:\Test\OriginalFile.PDF")

pdfDoc.Optimize()

pdfDoc.Save("C:\Test\NewFile.PDF")


Hi Brent,

Thanks for sharing the sample source code.

I tested the scenario and able to notice the same problem. For rectification, I logged this problem with ID: PDFNEWNET-33554 in our Issue Tracking System. We will further look into the details of this issue and will keep you updated via this forum thread on the status of correction.

We apologize for your inconvenience.

Thanks & Regards,

Any update on this?

Hi Brent,


Thanks for your inquiry. While testing the reported issue with latest API, the exception issue has been fixed but there is no change in size of resultant optimized document. I’ve shared the findings with development team and requested for an ETA. As soon as I get a feedback, I’ll update you via this forum thread.

Sorry for the inconvenience faced.

Best Regards,

Hi Brent,


Thanks for your inquiry. We have further investigated the issue and would like to update you that the file is successfully saved and after save it is linearized according to Adobe Acrobat. File size change should not be expected because this methods is only to make file linearized for web optimization. For optimizing PDF file size please check following link for the purpose.


Please feel free to contact us for any further assistance.

Best Regards,