Syncfusion AI Assistant

How can I help you?

Bookmarks in Blazor DocumentEditor Component

17 Oct 20251 minute to read

A bookmark is a powerful tool that marks a specific place in a document so you can easily find it again. You can insert multiple bookmarks in a document and give each one a unique name for easy identification.

The Blazor Word Processor (Document Editor) provides two ways to manage bookmarks: through a built-in dialog or programmatically using API methods. Once a bookmark is added, you can jump to its location or create hyperlinks to it.

NOTE

Bookmark names need to begin with a letter. They can include both numbers and letters, but not spaces. To separate the words, use an underscore. Bookmark names starting with an underscore are called hidden bookmarks. For example, bookmarks generated for table of contents.

The bookmark dialog can be opened using the Bookmark option in the toolbar. For more details on bookmark functionality, refer to the Blazor Word Processor - Bookmark example.

Add a bookmark

Use the InsertBookmarkAsync method to add a bookmark to the currently selected text.

await container.DocumentEditor.Editor.InsertBookmarkAsync("Bookmark1");

Use the SelectBookmarkAsync method to navigate to and select a bookmark by its name.

await container.DocumentEditor.Selection.SelectBookmarkAsync("Bookmark1");

Delete a Bookmark

Use the DeleteBookmarkAsync method to delete a bookmark by its name.

await container.DocumentEditor.Editor.DeleteBookmarkAsync("Bookmark1");

Get all bookmarks

Use the GetBookmarksAsync method to retrieve a list of all bookmarks in the document.

// Get all bookmarks, including hidden ones.
await container.DocumentEditor.Selection.GetBookmarksAsync(true);

NOTE

The boolean parameter of GetBookmarksAsync specifies whether to include hidden bookmarks in the result. If false, hidden bookmarks are excluded.