GetText
Returns the inner text of the current document content object.
Syntax
expression.GetText(options);
expression - A variable that represents an ApiRichContent class.
Parameters
| Name | Required/Optional | Data type | Default | Description |
|---|---|---|---|---|
| options | Optional | object | Options for formatting the returned text. | |
| options.ParaSeparator | Optional | string | '\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.TabSymbol | Optional | string | '\t' | Defines how the tab will be specified in the resulting string. Any symbol can be used. The default symbol is "\t". |
| options.NewLineSeparator | Optional | string | '\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`);