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

Free Support Forum - aspose.com

Unable to flatten a PDF

Hi,

Environment: .Net 4.0, Aspose.pdf.10.3.0

I am unable to flatten a (attached example) pdf document by using the following code:

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(filename);
Aspose.Pdf.PageCollection pageCollection = pdfDocument.Pages;
Aspose.Pdf.Page pdfPage = pageCollection[1];
pdfDocument.Flatten();
This is the exception:

{“Message”:“An error has occurred.”,
“ExceptionMessage”:“Object reference not set to an instance of an object.”,
“ExceptionType”:“System.NullReferenceException”,
“StackTrace”:" at Aspose.Pdf.InteractiveFeatures.Annotations.Annotation.\u001d\u0014(\u0003\u000e\u0013 , Page )\r\n
at Aspose.Pdf.Page.\u000e\u0010(\u0003\u000e\u0013 )\r\n
at Aspose.Pdf.Page.\b(Boolean )\r\n
at Aspose.Pdf.Document.()\r\n
at Aspose.Pdf.Document.Flatten()\r\n
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()\r\n at System.Threading.Tasks.Task.Execute()"}

The document is saved as PDF from a webpage using selectPDF tool. Can you please help with understanding how to resolve this issue?

Thank you,
Sireesha

Hi Sireesha,


Thanks for your inquiry. I have tested the scenario using Aspose.Pdf for .NET 11.5.0 and unable to notice the reported exception. Please download and try latest version of Aspose.Pdf for .NET, it will resolve the issue.

Best Regards,