Builder.InsertHTML() Functionality for bookmarks


#1

I need to be able to insert HTML into a bookmark with automatic HTML to RTF conversion similar to how Builder.InsertHTML() works.

Examle: Bookmark.InsertHTML().

Is this possible?


#2

If you want to insert HTML inside bookmark immediately after bookmark start then you should use the following code:

DocumentBuilder builder = new DocumentBuilder(doc);

builder.MoveToBookmark("bm1", true, true);

builder.InsertHtml("Inserted Html 1.

Inserted Html 2.");

If you want to substitute the existing bookmark text with the inserted HTML then you should clean up bookmark text before insertion like this:

DocumentBuilder builder = new DocumentBuilder(doc);

doc.Range.Bookmarks["bm1"].Text = string.Empty;

builder.MoveToBookmark("bm1", true, true);

builder.InsertHtml("Inserted Html 1.

Inserted Html 2.");

As for automatic RTF conversion - sorry, I don't understand what is meant here. Please clarify.

Best regards,