Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-pdftotext

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-pdftotext

A simple light weight react package to extract plain text from a pdf file.

  • 1.3.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.4K
increased by1.55%
Maintainers
0
Weekly downloads
 
Created
Source

react-pdftotext

Light-weight memory-safe client library for extracting plain text from pdf files.

Installing

Using npm:

npm install react-pdftotext

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";

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'

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.

Keywords

FAQs

Package last updated on 17 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc