Search results

Extract Text

03 Dec 2021 / 1 minute to read

The PDF Viewer library allows you to extract the text from a page along with the bounds. Text extraction can be done using the isExtractText property and extractTextCompleted event.

Step 1: Follow the steps provided in the link to create simple PDF Viewer sample.

Step 2: The following code snippet explains how to extract the text from a page.

Copied to clipboard
    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