react-pdftotext-temppackage
v1.0.5
Published
A simple light weight react package to extract plain text from a pdf file.
Downloads
35
Maintainers
Readme
react-pdftotext
Light-weight memory-safe client library for extracting plain text from pdf files.
Installing
Using npm:
npm install react-pdftotext-temppackage
Example
Local File Input
Now add a input tag with type="file" to take file input.
<input type="file" accept="application/pdf" onChange={extractText} />
Import the pdf2text function from package
import pdfToText from "react-pdftotext-temppackage";
function extractText(event) {
const file = event.target.files[0];
pdfToText(file)
.then((text) => console.log(text))
.catch((error) => console.error("Failed to extract text from pdf"));
}
Remote PDF File Input
For Pdf files stored at remote locations
import pdfToText from 'react-pdftotext-temppackage'
const pdf_url = "REMOTE_PDF_URL"
function extractText() {
const file = await fetch(pdf_url)
.then(res => res.blob())
.catch(error => console.error(error))
pdfToText(file)
.then(text => console.log(text))
.catch(error => console.error("Failed to extract text from pdf"))
}
Contributing
This project welcomes contributions and suggestions. This project was forked from react-pdftotext (https://www.npmjs.com/package/react-pdftotext). This is intended as a temporary bug patch.