How to put a picture into a bookmark

Hi,
i’d like to put a picture into a bookmark in a .doc document.
Thanks for your help.
yohannver

Hi,

Doing that by means of Aspose.Words is fairly easy:

Document doc = new Document("MyDocument.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToBookmark("MyBookmark");
builder.InsertImage("MyImage.jpg");

Thanks to your reply DmitryV.
I have got another problem at this page.
Thank you
Yohann

Hi!
I can insert my picture into the bookmark but if there is something in the bookmark before, this is not erased. How could I do it?
Thanks

The simplest method of cleaning bookmark content is setting Bookmark.Text property to an empty string.

However, that will work only for the simplest of bookmarks. For bookmark spanning multiple nodes with mixed content, like several paragraphs and tables, it can fail with “Start and end node should have the same grand parent” exception.

So if your bookmark is simple, then just set its Text property to an empty string. If it is not - use workaround code provided in the following Aspose.Words blog article:
https://blog.aspose.com/2007/03/13/remove-bookmarks-in-word-doc-docx-using-csharp-.net-word-library/

Oh ok I tried with an empty string and it works
Can you help me too with this problem ?
Thank you

Sure. Just give me some time, I am going to provide a comprehensive code example for you.