Extract texts in EJ2 TypeScript Pdfviewer control

13 Jul 20241 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