Giter Club home page Giter Club logo

react-pdftotext's Introduction

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.

react-pdftotext's People

Contributors

ajcav2 avatar john-royal avatar utkarsh212 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

react-pdftotext's Issues

Extracts text with spaces after each character

Hello @Utkarsh212 ! Thanks for the react-pdftotext. It works great 99% of the time. But I got a strange extraction with some pdfs. I attached one as an example.

example.pdf

The result of the extraction looks like this:

T h e   a c c e p t s   2 0   r e q u e s t s   p e r   s e c o n d ,   b u t   f u r t h e r   s e n d i n g   i s   d i s t r i b u t e d   o v e r   t i m e   t o   s m o o t h   o u t   t h e   l o a d   a n d  n o t   e x c e e d   t h e   A P I   l i m i t s   o f   t h e   m e s s e n g e r .  @ P l a t f o r m  I s   t h e r e   a   l i m i t   o n   t h e   n u m b e r   o f   o p e n   c h a t s   p e r   ? @ C o m p a n y  T h e r e   a r e   n o   l i m i t s   o n   o p e n   c h a t s .

Do you have any idea how to fix this?

Error: Connection Failure When Uploading Remote PDF URLs

Issue Summary:
When attempting to upload and parse remote PDF URLs using our current backend implementation, the process fails with a connection error. This issue occurs despite the successful parsing of locally uploaded PDF files.

Expected Behavior:
The backend should successfully fetch the PDF from the remote URL, parse its content, and return the extracted text to the frontend.

Actual Behavior:
The backend fails to fetch the PDF from the remote URL, resulting in a connection error. This error does not occur with locally uploaded PDF files.
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.