To remove hyperlink from pdf

PDF is visible as normal text like , But when the cursour is placed to this text, it displays as hyperlink, Do we have option to remove this kind of Hyperlink from the document.

Any Suggestions?

Hi Prakash,

Thanks for contacting support and sorry for the delayed response.

I am afraid currently Aspose.Pdf for Java does not support the feature to remove hyperlink from PDF contents. For the sake of correction, I have logged this requirement as PDFNEWJAVA-34106 in our issue tracking system. We will further
look into the details of this requirement and will keep you updated on the status
of correction. Please be patient and spare us little time. We are sorry for
this inconvenience.

I thought of sharing my experience so that it can be useful for others. This is default behavior of adobe. You can change this behavior using preferences->General->Un check “create links from URLS”


Thank you for sharing your worthy findings.

You are right because there are not any links and the PDF viewers usually convert a text which matches to link or email format while making it active by itself.

Moreover, we would also like to add a workaround for such scenarios. One can override the default link by LinkAnnotation configured with empty GoToAction. Below is a code snippet for implementing the same:

// load the PDF file
Document doc = new Document(myDir+"HyperlinkRemoved.pdf");

//create TextAbsorber object to find all the phrases matching the regular expression for hyperlink of e-mail
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("(\\b(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|])|((([a-zA-Z]|[0-9])|([-]|[_]|[.]))+[@](([a-zA-Z0-9])|([-])){2,63}[.](([a-zA-Z0-9]){2,63})+$)");
//set text search option to specify regular expression usage
TextSearchOptions textSearchOptions = new TextSearchOptions(true);

int pageNum = 1;
//accept the absorber for all the pages
Page page =  doc.getPages().get_Item(pageNum);
//get the extracted text fragments
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.getTextFragments();
//loop through the fragments
for (TextFragment textFragment : textFragmentCollection)
    LinkAnnotation linkAnnot = new LinkAnnotation(page, textFragment.getRectangle());
    linkAnnot.setBorder(new Border(linkAnnot));