GetText

function GetText(
  oPr: object = null,
  oPr.NewLineParagraph: boolean = false,
  oPr.Numbering: boolean = false,
  oPr.Math: boolean = false,
  oPr.NewLineSeparator: string = '\r',
  oPr.TableCellSeparator: string = '\t',
  oPr.TableRowSeparator: string = '\r\n',
  oPr.ParaSeparator: string = '\r\n',
  oPr.TabSymbol: string = '\t',
): String

Description

Returns a text from the specified range.

Parameters

oProbjectdefault: null

The resulting string display properties.

oPr.NewLineParagraphbooleandefault: false

Defines if the resulting string will include paragraph line boundaries or not.

oPr.Numberingbooleandefault: false

Defines if the resulting string will include numbering or not.

oPr.Mathbooleandefault: false

Defines if the resulting string will include mathematical expressions or not.

oPr.NewLineSeparatorstringdefault: '\r'

Defines how the line separator will be specified in the resulting string.

oPr.TableCellSeparatorstringdefault: '\t'

Defines how the table cell separator will be specified in the resulting string.

oPr.TableRowSeparatorstringdefault: '\r\n'

Defines how the table row separator will be specified in the resulting string.

oPr.ParaSeparatorstringdefault: '\r\n'

Defines how the paragraph separator will be specified in the resulting string.

oPr.TabSymbolstringdefault: '\t'

Defines how the tab will be specified in the resulting string (does not apply to numbering)

Returns

String

Try It

var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
oParagraph.AddText("\tONLYOFFICE Document Builder");
var oRange = oDocument.GetRange(0, 24);
var sText = oRange.GetText({"Numbering": true, "Math": true, "NewLineSeparator": "\r", "TabSymbol": "\t", "NewLineParagraph": true, "TableCellSeparator": "\t", "TableRowSeparator": "\r\n", "ParaSeparator": "\r\n"});
oParagraph = Api.CreateParagraph();
oParagraph.AddText("The text of the specified range: " + sText);
oDocument.Push(oParagraph);

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).