We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

replace text in a WordDocument by an hyperlink ?

Thread ID:

Created:

Updated:

Platform:

Replies:

123801 Apr 22,2016 08:31 AM UTC Apr 27,2016 05:16 AM UTC WPF 3
loading
Tags: DocIO
fff
Asked On April 22, 2016 08:31 AM UTC

Hi,

I am currently using: mydoc.Replace("this", "bythat", false, false);

--> But how to replace "this" by an hyperlink ?

Thanks,
F

Suganya Rathinam [Syncfusion]
Replied On April 25, 2016 06:22 AM UTC

Hi Fabrice,

Thank you for contacting Syncfusion support.

DocIO provides support to replace the text with a new
TextBodyPart. The hyperlink can be placed inside the paragraph of a TextBodyPart which can be used to replace the text in the document. Please find the following code snippets for your requirement and let us know if it helps.

 
WordDocument document = new WordDocument(FileName); 
//Create a new paragraph  
WParagraph paragraph = new WParagraph(document); 
//Append hyperlink to the paragraph 
paragraph.AppendHyperlink("http://help.syncfusion.com/file-formats/docio/overview", "DocIO UG", HyperlinkType.WebLink); 
//Create new TextBodyPart and add the paragraph to it 
TextBodyPart textBodyPart = new TextBodyPart(document); 
textBodyPart.BodyItems.Add(paragraph); 
//Replace the text with the TextBodyPart 
document.Replace("this", textBodyPart, false, true); 
//Save and close the document 
document.Save(FileName, FormatType.Docx); 
document.Close(); 

Please find the following UG documentation link on Find and Replace functionality for more details.
http://help.syncfusion.com/file-formats/docio/working-with-find-and-replace

Regards,
Suganya


fff
Replied On April 26, 2016 11:20 AM UTC

That's great, giving huge flexibility, with more than just hyperlinks (not so obvious in the sf docs :) )

tanks a lot Suganya

BR,
Fabrice


Suganya Rathinam [Syncfusion]
Replied On April 27, 2016 05:16 AM UTC

Hi Fabrice,

Thank you for your feedback. Please get back to us if you need any further assistance.

Regards,
Suganya


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;