Skip to main content

GetText

Returns the inner text of the current document content object.

Syntax​

expression.GetText(options);

expression - A variable that represents an ApiRichContent class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
optionsOptionalobjectOptions for formatting the returned text.
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 text from rich content in a PDF.

// How can I access text stored in rich content in a PDF?

// Retrieve and display text from annotated content in a PDF.

let doc = Api.GetDocument();
let freeTextAnnot = Api.CreateFreeTextAnnot([160, 50, 360, 135]);
let page = doc.GetPage(0);
page.AddObject(freeTextAnnot);
freeTextAnnot.SetIntent("freeTextCallout");
freeTextAnnot.SetCallout([{x: 161, y: 51}, {x: 249, y: 125}, {x: 261, y: 125}]);
freeTextAnnot.SetRectDiff([100, 64, 0.5, 0.5]);

let richContent = freeTextAnnot.GetContent();
let para = Api.CreateRichParagraph();
para.AddText("Example text");
richContent.Push(para);

console.log(`Rich content contains "${richContent.GetText()}" text`);