You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Below mentioned text will be present in our TEST.docx file.
sample example paragraph:
To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other.
For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
We want Implement following requirements using DocX API
Load "TEST.docx" File using DocX API.
Identify the following text "Click Insert" in document and find its start and end index
Mark "Click Insert" as hyperlink element and save the document.
Please let us know is there any way to achieve this using DocX API.
Regards,
Arun
The text was updated successfully, but these errors were encountered:
@arunln This is a 2 year old comment so I assume this problem is far in your rear view, so I am commenting for anyone else who may find this useful.
I found a workaround to inserting Hyperlinks into a document where an arbitrary text string is located. Obviously there's performance implications to this, but it works in the interim until the maintainers add this functionality.
// create a hyperlink
Hyperlink linkedTitle = document.AddHyperlink(content, new Uri(href));
// FindAll returns a List of starting indexes where your string was found
List<int> textMatchIndexes = document.FindAll(stringToMatch, RegexOptions.IgnoreCase);
// hack to insert (insert a paragraph because you can insert at an index)
foreach (int index in textMatchIndexes)
{
// insert p at index
var p = document.InsertParagraph(index, "", false);
// add hyper link to it
p.AppendHyperlink(linkedTitle).Color(Color.Blue).UnderlineStyle(UnderlineStyle.singleLine);
}
// replace placeholder text with empty string
document.ReplaceText(stringToMatch, "", false, RegexOptions.IgnoreCase);
Hi,
in the next release, v1.6, a new method will be available to replace a string by an hyperlink :
ReplaceTextWithObject( string searchValue, DocumentElement objectToAdd )
Thank you.
Hi Team,
Below mentioned text will be present in our TEST.docx file.
sample example paragraph:
To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other.
For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries.
We want Implement following requirements using DocX API
Please let us know is there any way to achieve this using DocX API.
Regards,
Arun
The text was updated successfully, but these errors were encountered: