1.0.2 • Published 1 year ago

node-react-pdf-extractor v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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);
}