Use extractTextCompleted to extract text in JavaScript PDF Viewer

14 Jan 20261 minute to read

Use the isExtractText property and the extractTextCompleted event to extract page text along with bounds.

The following example shows how to enable text extraction and handle the completion event:

viewer.isExtractText = true;
viewer.extractTextCompleted = args => {
    //Extract the Complete text of load document
    console.log(args);
    console.log(args.documentTextCollection[1]);
    //Extract the Text data.
    console.log(args.documentTextCollection[1][1].TextData);
    //Extract Text in the Page.
    console.log(args.documentTextCollection[1][1].PageText);
    //Extracts the first text of the PDF document along with its bounds
    console.log(args.documentTextCollection[1][1].TextData[0].Bounds);
};

Find the sample: How to extract text

See Also

Find Text
Text Search Events
Text Search Features
Extract Text
Extract Text Options