Skip to main content

GetText

Returns the inner text of the current document content object.

Syntax

expression.GetText(options);

expression - A variable that represents a ApiDocumentContent class.

Parameters

NameRequired/OptionalData typeDefaultDescription
optionsOptionalobjectOptions for formatting the returned text.
options.NumberingOptionalbooleantrueDefines if the resulting string will include numbering or not.
options.MathOptionalbooleantrueDefines if the resulting string will include mathematical expressions or not.
options.TableCellSeparatorOptionalstring'\t'Defines how the table cell separator will be specified in the resulting string. Any symbol can be used. The default separator is "\t".
options.TableRowSeparatorOptionalstring'\r\n'Defines how the table row separator will be specified in the resulting string. Any symbol can be used. The default separator is "\r\n".
options.ParaSeparatorOptionalstring'\r\n'Defines how the paragraph separator will be specified in the resulting string. Any symbol can be used. The default separator is "\r\n".
options.TabSymbolOptionalstring'\t'Defines how the tab will be specified in the resulting string. Any symbol can be used. The default symbol is "\t".
options.NewLineSeparatorOptionalstring'\r'Defines how the line separator will be specified in the resulting string. Any symbol can be used. The default separator is "\r".

Returns

string

Example

Extract all text from a document content container as a plain string in a document.

// How do I read the full text stored inside a document content object in a document?

// Verify the text inside a content control by reading it back as a single string.

const doc = Api.GetDocument();

const blockLvlSdt = Api.CreateBlockLvlSdt();
doc.Push(blockLvlSdt);

const content = blockLvlSdt.GetContent();
content.GetElement(0).AddText("This is a block text content control.");

const para = Api.CreateParagraph();
para.AddText("This text from DocContent element: " + content.GetText());
doc.Push(para);