Bookmarks in Blazor DOCX Editor

14 Aug 20261 minute to read

A bookmark 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 DOCX Editor (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 letters and numbers, but not spaces. To separate words in a name, use an underscore. Bookmark names starting with an underscore are called hidden bookmarks. For example, bookmarks generated for the table of contents.

Open the bookmark dialog 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.

Online demo

Explore how to insert and manage bookmarks in Word documents using the Blazor Document Editor in this live demo.