Bookmark
A Bookmark refers to a location in the document and has a unique name, which identifies it. Every Bookmark has a corresponding BookmarkRangeStart and BookmarkRangeEnd, which are inline elements. These two elements specify the bookmark location as follows:
BookmarkRangeStart: Specifies the start of a bookmark annotation.BookmarkRangeEnd: Specifies the end of a bookmark annotation.
Inserting a Bookmark
Example 1 shows how to create a Bookmark and add its BookmarkRangeStart and BookmarkRangeEnd elements in a Paragraph:
Example 1: Add a Bookmark to a Paragraph
Bookmark bookmark = new Bookmark(document, "MyBookmark");
paragraph.Inlines.Add(bookmark.BookmarkRangeStart);
paragraph.Inlines.AddRun("text");
paragraph.Inlines.Add(bookmark.BookmarkRangeEnd);
The paragraph must belong to the same document that is passed to the constructor of the Bookmark object. Otherwise, an exception is thrown. The bookmark location is specified around a run with text "text".
You can also insert a Bookmark in the document with the RadFlowDocumentEditor class as shown in Example 2:
Example 2: Insert a Bookmark Using RadFlowDocumentEditor
RadFlowDocumentEditor editor = new RadFlowDocumentEditor(new RadFlowDocument());
Bookmark bookmark = editor.InsertBookmark("MyBookmark");
The InsertBookmark() method from Example 2 creates a Bookmark with name "MyBookmark" and inserts its BookmarkRangeStart and BookmarkRangeEnd elements one after another.
Removing a Bookmark
You can remove an inserted Bookmark by using the DeleteBookmark() method of RadFlowDocumentEditor. Pass the name of the bookmark to remove, or the Bookmark instance itself, to the method.
Example 3 demonstrates how to delete the bookmark created in Example 2.
Example 3: Delete a Bookmark Using RadFlowDocumentEditor
editor.DeleteBookmark("MyBookmark");