Skip to main content

GetText

Returns the paragraph text.

Syntax​

expression.GetText(options);

expression - A variable that represents an ApiRichParagraph class.

Parameters​

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

// How do I read the text content from a paragraph in a PDF?

// Retrieve the complete text string from a paragraph 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 = richContent.GetElement(0);
let run = para.GetElement(0);
run.AddText("Some text");

console.log(`Rich paragraph text is: ${para.GetText()}`);