Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ layout: post
title: Retrieve the bookmark content as text in JavaScript (ES5) Document editor control | Syncfusion
description: Learn here all about Retrieve the bookmark content as text in Syncfusion JavaScript (ES5) Document editor control of Syncfusion Essential JS 2 and more.
platform: document-processing
control: Retrieve the bookmark content as text
control: Retrieve the Bookmark Content as Text
documentation: ug
domainurl: ##DomainURL##
---
Expand All @@ -12,9 +12,9 @@ domainurl: ##DomainURL##

You can get the bookmark or whole document content from the [JavaScript DOCX Editor](https://www.syncfusion.com/docx-editor-sdk/javascript-docx-editor) (Document Editor) component as plain text and SFDT (rich text).

## Get the bookmark content as plain text
## Get the Bookmark Content as Plain Text

You can [`selectBookmark`](../bookmark#select-bookmark) API to navigate to the bookmark and use [`text`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/selection#text-code-classlanguage-textstringcode) API to get the bookmark content as plain text from JavaScript Document Editor component.
You can use the [`selectBookmark`](../bookmark#select-bookmark) API to navigate to the bookmark and use the [`text`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/selection#text-code-classlanguage-textstringcode) API to get the bookmark content as plain text from the Document Editor.

The following example code illustrates how to get the bookmark content as plain text.

Expand All @@ -28,27 +28,27 @@ let container: DocumentEditorContainer = new DocumentEditorContainer({ enableToo
container.serviceUrl = 'https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/';

container.appendTo('#container');
// To insert text in cursor position
// To insert text at the cursor position
container.documentEditor.editor.insertText('Document editor');
// To select all the content in document
// To select all the content in the document
container.documentEditor.selection.selectAll();
// Insert bookmark to selected content
container.documentEditor.editor.insertBookmark('Bookmark1');

// Provide your bookmark name to navigate to specific bookmark
// Provide your bookmark name to navigate to a specific bookmark
container.documentEditor.selection.selectBookmark('Bookmark1');

// To get the selected content as text
let selectedContent: string = container.documentEditor.selection.text;
```

> The Web API hosted link `https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/` utilized in the Document Editor's serviceUrl property is intended solely for demonstration and evaluation purposes. For production deployment, please host your own web service with your required server configurations. You can refer and reuse the [GitHub Web Service example](https://github.com/SyncfusionExamples/EJ2-DocumentEditor-WebServices) or [Docker image](https://hub.docker.com/r/syncfusion/word-processor-server) for hosting your own web service and use for the serviceUrl property.
N> The Web API hosted link `https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/` utilized in the Document Editor's serviceUrl property is intended solely for demonstration and evaluation purposes. For production deployment, please host your own web service with your required server configurations. You can refer and reuse the [GitHub Web Service example](https://github.com/SyncfusionExamples/EJ2-DocumentEditor-WebServices) or [Docker image](https://hub.docker.com/r/syncfusion/word-processor-server) for hosting your own web service and use for the serviceUrl property.

To get the bookmark content as SFDT (rich text), please check this [`link`](../how-to/get-the-selected-content#get-the-selected-content-as-sfdt-rich-text)
To get the bookmark content as SFDT (rich text), please refer to this [`link`](../how-to/get-the-selected-content#get-the-selected-content-as-sfdt-rich-text).

## Get the whole document content as text
## Get the Whole Document Content as Text

You can use [`text`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/selection#text-code-classlanguage-textstringcode) API to get the whole document content as plain text from JavaScript Document Editor component.
You can use the [`text`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/selection#text-code-classlanguage-textstringcode) API to get the whole document content as plain text from the Document Editor.

The following example code illustrates how to get the whole document content as plain text.

Expand All @@ -62,20 +62,20 @@ let container: DocumentEditorContainer = new DocumentEditorContainer({ enableToo
container.serviceUrl = 'https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/';

container.appendTo('#container');
// To insert text in cursor position
// To insert text at the cursor position
container.documentEditor.editor.insertText('Document editor');
// To select all the content in document
// To select all the content in the document
container.documentEditor.selection.selectAll();

// To get the content as text
let selectedContent: string = container.documentEditor.selection.text;
```

> The Web API hosted link `https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/` utilized in the Document Editor's serviceUrl property is intended solely for demonstration and evaluation purposes. For production deployment, please host your own web service with your required server configurations. You can refer and reuse the [GitHub Web Service example](https://github.com/SyncfusionExamples/EJ2-DocumentEditor-WebServices) or [Docker image](https://hub.docker.com/r/syncfusion/word-processor-server) for hosting your own web service and use for the serviceUrl property.
N> The Web API hosted link `https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/` utilized in the Document Editor's serviceUrl property is intended solely for demonstration and evaluation purposes. For production deployment, please host your own web service with your required server configurations. You can refer and reuse the [GitHub Web Service example](https://github.com/SyncfusionExamples/EJ2-DocumentEditor-WebServices) or [Docker image](https://hub.docker.com/r/syncfusion/word-processor-server) for hosting your own web service and use for the serviceUrl property.

## Get the whole document content as SFDT(rich text)
## Get the Whole Document Content as SFDT (Rich Text)

You can use [`serialize`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor#serialize) API to get the whole document content as SFDT string from JavaScript Document Editor component.
You can use the [`serialize`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor#serialize) API to get the whole document content as an SFDT string from the Document Editor.

The following example code illustrates how to get the whole document content as SFDT.

Expand All @@ -89,17 +89,17 @@ let container: DocumentEditorContainer = new DocumentEditorContainer({ enableToo
container.serviceUrl = 'https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/';

container.appendTo('#container');
// To insert text in cursor position
// To insert text at the cursor position
container.documentEditor.editor.insertText('Document editor');

// To get the content as SFDT
let selectedContent: string = container.documentEditor.serialize();
```


## Get the header content as text
## Get the Header Content as Text

You can use [`goToHeader`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/selection#gotoheader) API to navigate the selection to the header and then use [`text`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/selection#text-code-classlanguage-textstringcode) API to get the content as plain text.
You can use the [`goToHeader`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/selection#gotoheader) API to navigate the selection to the header and then use the [`text`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/selection#text-code-classlanguage-textstringcode) API to get the content as plain text.

The following example code illustrates how to get the header content as plain text.

Expand All @@ -113,17 +113,17 @@ let container: DocumentEditorContainer = new DocumentEditorContainer({ enableToo
container.serviceUrl = 'https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/';

container.appendTo('#container');
// To navigate the selection to header
// To navigate the selection to the header
container.documentEditor.selection.goToHeader();
// To insert text in cursor position
// To insert text at the cursor position
container.documentEditor.editor.insertText('Document editor');
// To select all the content in document
// To select all the content in the document
container.documentEditor.selection.selectAll();

// To get the selected content as text
let selectedContent: string = container.documentEditor.selection.text;
```

> The Web API hosted link `https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/` utilized in the Document Editor's serviceUrl property is intended solely for demonstration and evaluation purposes. For production deployment, please host your own web service with your required server configurations. You can refer and reuse the [GitHub Web Service example](https://github.com/SyncfusionExamples/EJ2-DocumentEditor-WebServices) or [Docker image](https://hub.docker.com/r/syncfusion/word-processor-server) for hosting your own web service and use for the serviceUrl property.
N> The Web API hosted link `https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/` utilized in the Document Editor's serviceUrl property is intended solely for demonstration and evaluation purposes. For production deployment, please host your own web service with your required server configurations. You can refer and reuse the [GitHub Web Service example](https://github.com/SyncfusionExamples/EJ2-DocumentEditor-WebServices) or [Docker image](https://hub.docker.com/r/syncfusion/word-processor-server) for hosting your own web service and use for the serviceUrl property.

Similarly, you can use [`goToFooter`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/selection#gotofooter) API to navigate the selection to the footer and then use [`text`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/selection#text-code-classlanguage-textstringcode) API to get the content as plain text.
Similarly, you can use the [`goToFooter`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/selection#gotofooter) API to navigate the selection to the footer and then use the [`text`](https://ej2.syncfusion.com/javascript/documentation/api/document-editor/selection#text-code-classlanguage-textstringcode) API to get the content as plain text.
Loading