I am trying to insert HTML in my word document. I am able to do it. The problem is every time I use this method it appends the HTML content after the bookmark. My requirement is to replace the existing HTML(overwrite the content). Here is the code I am using:
Document wordDoc = new Document(@"D:\Projects\Aspose\Template.docx");
var bookmark = wordDoc.Range.Bookmarks["b_Edtions"];
wordDoc.Range.Bookmarks[bookmark.Name].Text = string.Empty;
var documentBuilder = new Aspose.Words.DocumentBuilder(wordDoc);
if (documentBuilder.MoveToBookmark(bookmark.Name, true, true))
{
string html_output = "<b>Dynamic HTML</b>";
documentBuilder.InsertHtml(html_output);
wordDoc.Save(@"D:\Projects\Aspose\TemplateFinal.docx");
}
Attaching document used in the above code.
Template.docx (49.0 KB)