Extract text in EJ2 JavaScript Pdfviewer control

8 May 20231 minute to read

To extract text in Syncfusion PDF viewer, you can use the isExtractText property and extractTextCompleted event.This allows you to extract the text from a page along with the bounds.

Here is an example of how you can use the isExtractText property and extractTextCompleted 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