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

Free Support Forum - aspose.com

Unable to remove LinkAnnotation objects in PDF created by Chrome

When you create a PDF using Chrome’s “Save as PDF” command, the links in the document are stored as annotations. Acrobat can read the file and the links work as expected. However, when we try to remove those links using Aspose.Pdf, we get a System.NullReferenceException.

Here is a test PDF that was created using a recent Chrome release: Test File.pdf (36.6 KB)

This document has 25 link annotations on the first page. The code to delete the first one would simply be:

Dim Document = New Aspose.Pdf.Document(SourcePath)

Dim Annotations = Document.Pages(1).Annotations

After executing the final line, we receive the null reference exception, but the count of the parent collection does go down. However, saving and reopening the document restores the annotation, so it’s not actually deleted.

If, instead, you try to flatten the LinkAnnotation using its Flatten method, the same failure happens. The Hyperlink property of the LinkAnnotation is null. The Action property of the LinkAnnotation is a GoToURIAction, and has the correct URI, which we’re able to change. We need to be able to remove it completely, though, so that won’t be adequate. Also, if you view the LinkAnnotation in the debugger, there’s a protected property called “message1” with the text “There is a problem with an annotation. Required entry is absent.”

Is there anything we can do to remove the LinkAnnotation objects from this document? The link works properly in Acrobat, and doesn’t appear to be missing anything that’s actually required, so I’m curious about the message1 value I mention above, and also curious about why we can’t remove the object.

Thanks for any information on this,
Michael Whalen

I just received some new information from my tester that might help. He says the document was created by printing from Chrome to the printer named “Adobe Acrobat PDF”, rather than a Save As command as I had originally been told.

Also, using the same technique from Firefox or IE/Edge does not produce the same results. I’m trying to get more info on that, as I don’t know if that means that it creates LinkAnnotation objects that aren’t causing the same problem, or if it just doesn’t create the LinkAnnotation objects at all from those browsers. I’ll update this topic when I know more.


Thanks for contacting support.

We have tried to delete the LinkAnnotation from shared document, while using Aspose.Pdf for .NET 17.9 and observed the same exception which you have reported.

Therefore, we have also logged an investigation ticket as PDFNET-43354 in our issue tracking system. We will further investigate the reason behind this behavior of the API and as soon as we have some results of our investigation, we will update you within this forum thread. Please be patient and spare us little time.

We are sorry for the inconvenience.

After collecting more information, I think it was just the way it was saved that created the links in the document, and probably didn’t have anything to do with Chrome or IE/Edge or Firefox. I say “I think” because one of our clients is the one actually having the problem, and we haven’t been able to perfectly replicate their scenario here (we have a very similar repro, but there’s some setting difference we haven’t spotted yet). We did create the sample document I attached above (that’s not from the client) so we’ve seen the issue, I just think the browser involved isn’t important information and now think I should have left that part out. Thanks for looking into the issue.


Thanks for your feedback and acknowledgment.

As we have already logged an investigation ticket with the document and all shared information about it, so our product team will definitely look into this as per their development schedule. However, we have shared your latest feedback and acknowledgment with them as well. In case if we have any updates from their side, we will let you know. Please keep using our API and in case of any further inquiry, please feel free to contact us.


Could you please try using Aspose.PDF for .NET 21.12 and let us know in case the issue still persists.

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