Bookmarks
18 Jan 20242 minutes to read
Bookmark is a powerful tool that helps to mark a place in the document to find again easily. You can enter many bookmarks in the document and give each one a unique name to identify easily.
Document editor provides built-in dialog to add, delete, and navigate bookmarks within the document. To add a bookmark, select a portion of text in the document. After that, jump to the location or add links to it within the document using built-in hyperlink dialog. You can also delete bookmarks from a document.
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.
Add bookmark
Using [insertBookmark
] method, Bookmark can be added to the selected text.
container.documentEditor.editor.insertBookmark("Bookmark1");
Select Bookmark
You can select the bookmark in the document using [selectBookmark
] method by providing Bookmark name to select as shown in the following code snippet.
container.documentEditor.selection.selectBookmark("Bookmark1");
Delete Bookmark
You can delete bookmark in the document using [deleteBookmark
] method as shown in the following code snippet.
container.documentEditor.editor.deleteBookmark("Bookmark1");
Get Bookmark
You can get all the bookmarks in the document using [getBookmarks
] method as shown in the following code snippet.
container.documentEditor.selection.getBookmarks(false);
NOTE
Parameter denotes is include hidden bookmarks. If false, ignore hidden bookmark.
Bookmark Dialog
The following example shows how to open bookmark dialog in Document Editor.
<ejs-button id="dialog">Dialog</ejs-button>
<div id="documenteditor" style="width:100%;height:100%" >
<ejs-documenteditor isReadOnly=false enableEditor=true enableSelection=true enableBookmarkDialog=true enableSfdtExport=true id="container"></ejs-documenteditor>
</div>
<script>
var documenteditor;
document.addEventListener('DOMContentLoaded', function () {
var documenteditorElement = document.getElementById("container");
documenteditor = documenteditorElement.ej2_instances[0];
documenteditor.resize();
var button = document.getElementById('dialog');
button.addEventListener('click', function () {
// To open Bookmark Dialog
documenteditor.showDialog('Bookmark');
});
});
</script>
public ActionResult Default()
{
return View();
}