Edit this page
Available for: UI for ASP.NET AJAX | UI for ASP.NET MVC | UI for WPF | UI for WinForms

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's 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:

[C#] Example 1: Add а bookmark to а paragraph

Bookmark bookmark = new Bookmark(document, "MyBookmark");
paragraph.Inlines.Add(bookmark.BookmarkRangeStart);
paragraph.Inlines.AddRun("text");
paragraph.Inlines.Add(bookmark.BookmarkRangeEnd);

Note, that the paragraph should belong to the same document that is passed to the constructor of the Bookmark object, otherwise an exception is thrown. The bookmark's location is specified around a run with text "text".

Inserting a Bookmark in the document can also be done with the RadFlowDocumentEditor class like shown in Example 2:

[C#] Example 2: Insert а 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 one after another its BookmarkRangeStart and BookmarkRangeEnd elements.

Removing a Bookmark

You can remove an inserted Bookmark by using RadFlowDocumentEditor's DeleteBookmark() method. You can pass to the method the name of the Bookmark to remove, or the Bookmark itself.

Example 3 demonstrates how you can delete the bookmark created in Example 2.

[C#] Example 2: Delete bookmark using RadFlowDocumentEditor

editor.DeleteBookmark("MyBookmark");

See Also