A simple light weight react package to extract plain text from a pdf file.
npm install react-pdftotext-advancedjs
npm install react-pdftotext-advanced
`
Example
Local File Input
Now add a input tag with type="file" to take file input.
`html
`
Import the pdf2text function from package
`ts
//simple mode
//input Base text
//Good morning everyone.
//
//How are you all?
//
//I hope you're well.
import pdfToText from "react-pdftotext-advanced";
function extractText(event) {
const file = event.target.files[0];
selectModeToExtract(file, 'simple')
.then((text) => console.log(text))
.catch((error) => console.error("Failed to extract text from pdf"));
}
//output Base text
// Good morning everyone.How are you all?I hope you're well.
`
`ts
//Advanced mode
//input text
//Good morning everyone.
//
//How are you all?
//
//I hope you're well.
import pdfToText from "react-pdftotext-advanced";
function extractText(event) {
const file = event.target.files[0];
selectModeToExtract(file, 'simple')
.then((text) => console.log(text))
.catch((error) => console.error("Failed to extract text from pdf"));
}
//output text
//Good morning everyone.
//
//How are you all?
//
//I hope you're well.
``