Remove hyperlinks from pdf files

I have a need to remove hyperlinks from documents as we convert them to PDF. This is to prevent a vulnerability that someone could embed a hyperlink to a malicious website. Is there a way to accomplish this with Aspose?

I found this 2014 support thread with someone else asking for this feature. Has it been implemented? To remove hyperlink from pdf


Thank you for contacting support.

Would you please share a sample PDF document so that we may investigate further and assist you accordingly.

Test embedded hyperlink.docx.pdf (8.9 KB)

This was a word doc that i added a link to google to. Went through aspose and still has a clickable link. Result I’d like to see is all hyperlinks stripped from the generated PDF files. Use case is that I have documents coming in from various sources that cannot be trusted. I’m converting them to PDF and don’t want to run the risk that the resulting document is linking to a dangerous place and the client reading the PDF could click on the hyperlink.


Thank you for sharing requested data.

Please try using below code snippet to remove hyperlinks from a PDF document, and then share your kind feedback with us.

// load the PDF file
Document doc = new Document(dataDir + "Test embedded hyperlink.docx.pdf");
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("");
int pageNum = 1;
//accept the absorber for first page
Page page = doc.Pages[pageNum];
//get the extracted text fragments
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
//loop through the fragments
foreach (TextFragment textFragment in textFragmentCollection)
        LinkAnnotation linkAnnot = new LinkAnnotation(page, textFragment.Rectangle);
        linkAnnot.Border = (new Border(linkAnnot));
        linkAnnot.Border.Width = (0);
doc.Save(dataDir + "HyperlinkRemoved_output_19.5.pdf");

We hope this will be helpful. Please feel free to contact us if you need any further assistance.