Socket
Socket
Sign inDemoInstall

pdf-parse2

Package Overview
Dependencies
68
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    pdf-parse2

A pure JavaScript, cross-platform module designed for extracting text from PDF files.


Version published
Weekly downloads
20
decreased by-28.57%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

version downloads license node type size

PDF Parse

A pure JavaScript, cross-platform module designed for extracting text from PDF files using pdf.js.

Features

  • Extract text from PDF files.
  • Supports both browser and Node.js environments.
  • Easy to use with promise-based API.

Installation

npm install pdf-parse2

Or

yarn add pdf-parse2

Usage

Node.js

const fs = require('fs');
const PDFParse = require('pdf-parse2');

(async () => {
  const dataBuffer = fs.readFileSync('path/to/your/document.pdf');
  const PDFParse = new PDFParse();

  try {
    const pdfData = await PDFParse.loadPDF(dataBuffer);
    console.log('Text:', pdfData.text);
  } catch (error) {
    console.error(error);
  }
})();

Browser

Ensure you include pdf.js library in your project. You can then use PDFParse similar to the Node.js example, but with fetching the PDF file using Fetch API or XMLHttpRequest.

API Reference

  • loadPDF(src, options): Loads a PDF file and extracts text. src can be a Buffer or ArrayBuffer. options is optional.

  • renderPage(pageData, options): A helper function for rendering a single page. This function is used internally by loadPDF.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request or open an issue for any bugs or feature requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Keywords

FAQs

Last updated on 15 Mar 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc