Skip to main content

GetText

Returns the paragraph text.

Syntax

expression.GetText(options);

expression - A variable that represents a ApiParagraph class.

Parameters

NameRequired/OptionalData typeDefaultDescription
optionsOptionalobjectOptions for formatting the returned text.
options.NumberingOptionalbooleanfalseDefines if the resulting string will include numbering or not.
options.MathOptionalbooleanfalseDefines if the resulting string will include mathematical expressions or not.
options.NewLineSeparatorOptionalstring'\r'Defines how the line separator will be specified in the resulting string. Any string can be used. The default separator is "\r".
options.TabSymbolOptionalstring'\t'Defines how the tab will be specified in the resulting string (does not apply to numbering). Any string can be used. The default symbol is "\t".

Returns

string

Example

Extract the plain text content of a paragraph in a document.

// How do I read the text string from a paragraph in a document?

// Retrieve paragraph text with custom separators and print it in a second paragraph in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("\tThis is just a sample text.");
let text = paragraph.GetText({"Numbering": true, "Math": true, "NewLineSeparator": "\r", "TabSymbol": "\t"});
paragraph = Api.CreateParagraph();
paragraph.AddText("The text of the first paragraph: " + text);
doc.Push(paragraph);