Skip to main content

GetSelectedText

Gets selected text on page

Syntax

expression.GetSelectedText();

expression - A variable that represents a ApiPage class.

Parameters

This method doesn't have any parameters.

Returns

string

Example

Extract the text that has been highlighted on a page in a PDF.

// How do I capture the text I've selected in a PDF?

// Retrieve what text is currently marked on a page in a PDF.

let doc = Api.GetDocument();
let page = doc.GetPage(0);
page.SetSelection({x: 10, y: 10}, {x: 100, y: 100});
console.log(`The selected text is: ${page.GetSelectedText()}`);