Hi
How can I change text in a word document to a hyperlink text using aspose .
Thanks
Hi Shinoj,
Thanks for your inquiry. I would suggest you to please visit the following link to be able to insert Hyperlinks in the document:
https://reference.aspose.com/words/net/aspose.words/documentbuilder/inserthyperlink/
I hope, this will help.
Best Regards,
I dont want to insert new hyper link.What I need is change an existing text from an existing document to hyper link;
For ex I need to change the text for each paragraph to the hyperlink;
foreach(Paragraph paragraph in paragraphs)
{
paragraph.Runs[0]..Text =
// @" HYPERLINK \\l 'toc' ";//" string.Format("HYPERLINK {0}\"{1}\"", ((mIsLocal) ? "\\l " : ""), paragraph.Runs[0].Text);
// paragraph.Runs[0].Text = "" + paragraph.Runs[0].Text + "";
}
Hi
Thanks for your request. I think, the code provided here could be useful for you:
https://forum.aspose.com/t/54204
Best regards,
Hi,
Thanks for the additional information. I think, in your case, the following code snippet should work:
DocumentBuilder builder = new DocumentBuilder(doc);
Paragraph paragraph = (Paragraph) doc.GetChildNodes(NodeType.Paragraph, true)[0];
string linkText = paragraph.Runs[0].Text;
paragraph.Runs[0].Text = string.Empty;
builder.MoveToParagraph(0, 0);
builder.InsertHyperlink(linkText, "http://www.aspose.com", false);
Please let us know if you need more information, We are always glad to help you.
Best Regards,