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

Free Support Forum - aspose.com

Insert hyperlink in place of text in pdf by .net c#

sir i want ot add some hyperlink in some text that i search in pdf file

via c# .net code please reply soon

This message was posted using Page2Forum from Data Extraction and other Utilities - Aspose.Pdf.Kit for .NET


Do you want to replace some text with an active – clickable – link or static link as simple text? Are you interested to add local link, to a page with in the PDF, or a link to a web page?

Please share the details of your requirement, so we could guide you accordingly.

I need to add a link to a web page in some existing text in a pdf document.

The document are built by a external system , i need to extract all the text from the pdf, evaluate it with same rules and add web link to piece of text when the rules are satisfied.

The pdf.kit is able to do this?

Thank you and regards

Davide Rovesti

Hi Davide,

I’m sorry to inform you that this requirement can not be fulfilled using the current version of Aspose.Pdf.Kit. However, I have logged a new feature request as PDFNEWNET-25741 in our issue tracking system. You’ll be notified via this forum thread once this feature is supported in future.

We’re sorry for the inconvenience.

Hi Davide,

Thanks for your patience. Please note you can use following code snippet to search in the document text fragment that matches regex pattern and to add hyperlink for this fragment.

//create absorber object to find all
instances of the input search phrase

TextFragmentAbsorber absorber = new TextFragmentAbsorber("F[a-z]{3}:");

//Enable regular expression search

absorber.TextSearchOptions = new TextSearchOptions(true);

//open document

PdfContentEditor editor = new PdfContentEditor();


//accept the absorber for the page


int[] dashArray = { };

String[] LEArray = { };

System.Drawing.Color blue = System.Drawing.Color.Blue;

//loop through the fragments

foreach (TextFragment textFragment in absorber.TextFragments)


textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.Blue;

System.Drawing.Rectangle rect = new System.Drawing.Rectangle((int)textFragment.Rectangle.LLX,

(int)Math.Round(textFragment.Rectangle.LLY), (int)Math.Round(textFragment.Rectangle.Width + 2),

(int)Math.Round(textFragment.Rectangle.Height + 1));

Enum[] actionName = new Enum[2] { PredefinedAction.Document_AttachFile, PredefinedAction.Document_ExtractPages };

editor.CreateWebLink(rect, "http://www.aspose.com", 1, blue, actionName);

editor.CreateLine(rect, "", (float)textFragment.Rectangle.LLX + 1, (float)textFragment.Rectangle.LLY - 1,

(float)textFragment.Rectangle.URX, (float)textFragment.Rectangle.LLY - 1, 1, 1, blue, "S", dashArray, LEArray);


//Save & Close the document



Please feel free to contact us for any further assistance.

Best Regards,

The issues you have found earlier (filed as PDFNEWNET-25741) have been fixed in Aspose.Pdf for .NET 9.8.0.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.