0

How can I extract data from PDF? But it already show error in console pdf2json.js is not defined

How can i get data from pdf and show on webpage? But its not working

  1. import pdf2json from "pdf2json"; add in app.js file

2)use reader.onload = function() { let pdfData = new Uint8Array(reader.result);

            // Step 5: Use pdf2json to parse the contents of the PDF and extract the text
            let pdfParser = new pdf2json(pdfData, 1);
            pdfParser.parse();
            let cvText = pdfParser.getTextContent();

            // Step 6: Use JavaScript to extract the name, email, and phone number from the text
            let name = extractName(cvText);
            let email = extractEmail(cvText);
            // let phone = extractPhone(cvText);

            // Step 7: Use JavaScript to update the selected elements with the extracted information
            let nameElement = document.getElementById("name");
            nameElement.textContent = name;
            let emailElement = document.getElementById("email");
            emailElement.textContent = email;
            // let phoneElement = document.getElementById("phone");
            // phoneElement.textContent = phone;
        }
        reader.readAsArrayBuffer(file);
    });
  1. But it show error pdfjson2. not defined

0 Answers0