HelpBot Assistant

How can I help you?

Use extractTextCompleted to extract text in JavaScript PDF Viewer

13 Feb 20261 minute to read

Use the isExtractText property together with the extractTextCompleted event to extract page text and its positional bounds from a loaded PDF document.

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