I have a PDF file, I want to remove Link Annotation Using Aspose.PDF for NET, But it does not take effect after processing. I try to output Annotations.Count
, But the result is 0
.
Version info
Aspose.PDF for Net 24.1
Sample code:
void Main()
{
var doc = new Aspose.Pdf.Document(@"C:\Users\54390\Downloads\demo.pdf");
doc.Pages.ToList().ForEach(page =>
{
page.Annotations.Count.Dump();//output 0.
page.Annotations.ToList().ForEach(annotation =>
{
if (annotation.AnnotationType == AnnotationType.Link)
{
page.Annotations.Delete(annotation);
}
});
});
doc.Save(@"C:\Users\54390\Downloads\output.pdf");
}
Demo file
demo.pdf (244.8 KB)
Screenshot
20240127223130.png (211.8 KB)
The red line area in the screenshot is a hyperlink.