GetText
Gets all text content on the page.
note
This functionality is available in paid ONLYOFFICE Docs editions.
Syntax
expression.GetText();
expression - A variable that represents an ApiPage class.
Parameters
This method doesn't have any parameters.
Returns
string
Example
Get all text content from a page in a PDF.
// Useful for reading the text on a PDF page.
// Extract page text after adding a shape with text content in a PDF.
let doc = Api.GetDocument();
doc.AddPage(0);
let page = doc.GetPage(0);
let fill = Api.CreateSolidFill(Api.RGB(50, 150, 250));
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
let shape = Api.CreateShape("rect", 150 * 36000, 80 * 36000, fill, stroke);
shape.SetPosition(10 * 12700, 10 * 12700);
let paragraph = shape.GetContent().GetElement(0);
paragraph.SetJc("left");
paragraph.AddText("Lorem selected text");
page.AddObject(shape);
console.log(`Page text is: ${page.GetText()}`);