Skip to content

bypawan/node-react-pdf-extractor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

node-react-pdf-extractor

A simple npm package to extract text content from PDF files. It supports both local file paths and remote URLs.

This package is fully compatible with Next JS and React on server side.

Requirements

  • Node.js
  • node-fetch package
  • pdftotext utility from the Poppler library

Installation

  1. Install Node.js (if not already installed):

  2. Install pdftotext:

    • On macOS, install via Homebrew:
      brew install poppler
    • On Ubuntu/Debian-based systems:
      sudo apt-get update
      sudo apt-get install poppler-utils
    • On Windows, download and install Poppler from Poppler for Windows. Ensure the directory containing pdftotext.exe is in your PATH.

Install PDF Extractor:

npm i node-react-pdf-extractor

Usage

Extract text from a remote PDF URL

import { extractPdf } from "node-react-pdf-extractor";

const url =
  "https://file-examples.com/storage/fed5266c9966708dcaeaea6/2017/10/file-example_PDF_500_kB.pdf";

try {
  const data = extractPdf(url);
  console.log("============== DATA", data);
} catch (error) {
  console.log("============== ERROR", error);
}

Extract text from a local PDF file

import { extractPdf } from "node-react-pdf-extractor";

const url = "./test.pdf";

try {
  const data = extractPdf(url);
  console.log("============== DATA", data);
} catch (error) {
  console.log("============== ERROR", error);
}

About

A simple npm package to extract text data from pdf inside React or Next JS projects.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published