Replace/Remove Bookmark content

Hi All,

This has been driving me crazy for some time now…so I’m asking for help!

We “process” our Word files by adding bookmarks around each paragraph. We then provided a Web UI that allows users to “edit” each paragraph in their browser and without needing Word. We do this by extracting the text from each bookmarked paragraph, displaying it in an HTML editor and then when they submit the changes, we want to replace the content of the bookmark with the new content they entered.

It’s the last bit that’s proving to be difficult in that I have found examples of how to delete bookmarks, including their content, but not to remove the content without removing the bookmark or just a simple replace of the content of a bookmark.

Does anybody have an examples or know how to do this??

Thanks.

Hi Andrew,


Thanks for your inquiry. Well, if the Bookmark’s content is always text then you can simply replace it using Bookmark.Text property. Please see examples in the following article:

Bookmarks in Aspose.Words

If it is more than text like Tables, Shapes etc then you can move cursor to bookmark and insert new nodes using DocumentBuilder.InsertNode method. Please let us know if we can be of any further assistance.

Best regards,