We have a PDF document that we’re trying to remove the annotations from and it’s failing on a single page of that document. I’ve extracted just that page and attached it below. Basically, using the attached document, attempt to run the following code:
Dim Document As Aspose.PDF.Document = New Aspose.PDF.Document(SourceFileName)
Document.Pages(1).Annotations(1).Flatten()
and you’ll receive a null reference exception in return. The same happens if you try the “Delete” method.
There were 10 pages total in the original document, with annotations on 9 of them, and this was the only page that had the issue. We were able to remove or flatten annotations from the other 8 pages that had them, so there’s something odd about this one page. It was also the 9th page in the original document, with the final page being the only one without annotations, so they were the last ones in the document, just in case that makes any difference. If you’d like, I can upload the original, as well.
Can someone help me figure out what’s wrong with those annotations and figure out a way to remove them? I notice there is a PdfAnnotationEditor object in the Aspose.Pdf.Facades namespace - should I be using that instead of going directly at the annotations off the page like we do in the code above?
Thanks for any help on this.
Michael Whalen
Sample.pdf (132.2 KB)