https://github.com/utkarsh212/react-pdftotext
Light-weight memory-safe client library for extracting plain text from pdf files.
https://github.com/utkarsh212/react-pdftotext
npm package pdf-document-processor pdf-to-text pdfjs react typescript
Last synced: 11 months ago
JSON representation
Light-weight memory-safe client library for extracting plain text from pdf files.
- Host: GitHub
- URL: https://github.com/utkarsh212/react-pdftotext
- Owner: Utkarsh212
- License: mit
- Created: 2024-02-23T09:59:17.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-17T18:45:18.000Z (over 1 year ago)
- Last Synced: 2025-06-26T01:41:02.027Z (11 months ago)
- Topics: npm, package, pdf-document-processor, pdf-to-text, pdfjs, react, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/react-pdftotext
- Size: 143 KB
- Stars: 19
- Watchers: 1
- Forks: 6
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-pdftotext
Light-weight memory-safe client library for extracting plain text from pdf files.
## Installing
Using npm:
```js
npm install react-pdftotext
```
## Example
**Local File Input**
Now add a input tag with type="file" to take file input.
```html
```
Import the pdf2text function from package
```js
import pdfToText from "react-pdftotext";
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
```js
import pdfToText from 'react-pdftotext'
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.