Articles in this section
Category / Section

How to remove hyperlink from existing PDF document?

1 min read

You can remove the hyperlink from existing document by using the “Remove” method available in the class “PdfLoadedAnnotationCollection”class. Please find the code snippet to remove the hyperlink from the existing document.

 

[C#]
 
//Load the file
PdfLoadedDocument lDoc = new PdfLoadedDocument("../../Data/TextWebLink.pdf");
 
for (int i = 0; i < lDoc.Pages.Count; i++)
{
//get the annotation collection
PdfAnnotationCollection annotColl = lDoc.Pages[i].Annotations as PdfLoadedAnnotationCollection;
 
for (int j = 0; j < annotColl.Count; j++)
{
//Get the annotaion
PdfLoadedAnnotation annot = annotColl[j] as PdfLoadedAnnotation;
 
 
if (annot is PdfLoadedTextWebLinkAnnotation || annot is PdfLoadedUriAnnotation)
{
 
//remove the hyperlinks
annotColl.Remove(annot);
 
}
}
 
}
 
lDoc.Save("Sample.pdf");
lDoc.Close(true);
 

 

Sample:

https://www.syncfusion.com/downloads/support/directtrac/general/ze/RemoveHyperlink-1083323766

 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment