🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

pdf-worker-package

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pdf-worker-package

A simple and robust PDF text extraction utility using pdfjs-dist

latest
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

PDF Worker Package

A simple and robust PDF text extraction utility using pdfjs-dist. This package provides an easy-to-use interface for extracting text content from PDF files.

Installation

npm install pdf-worker-package

Usage

import { processPDF } from 'pdf-worker-package';

// Example with Node.js
import * as fs from 'fs';

async function extractPDFText() {
  try {
    // Read the PDF file
    const pdfBuffer = fs.readFileSync('path/to/your/file.pdf');
    
    // Process the PDF and get the text
    const text = await processPDF(pdfBuffer);
    
    console.log('Extracted text:', text);
  } catch (error) {
    console.error('Error processing PDF:', error);
  }
}

// Example with browser
async function extractPDFTextFromFile(file: File) {
  try {
    const arrayBuffer = await file.arrayBuffer();
    const text = await processPDF(arrayBuffer);
    console.log('Extracted text:', text);
  } catch (error) {
    console.error('Error processing PDF:', error);
  }
}

API

processPDF(pdfData: ArrayBuffer): Promise<string>

Processes a PDF file and extracts its text content.

  • pdfData: The PDF file as an ArrayBuffer
  • Returns: A promise that resolves to the extracted text
  • Throws: Error if PDF processing fails

Error Handling

The package includes robust error handling for common PDF processing issues:

  • Worker initialization failures
  • Invalid PDF files
  • Processing errors
  • 👉 Need to clean and normalize text before embedding it?
    Check out text-prep-lite

  • 👉 Need word embeddings for semantic analysis?
    Check out wink-embeddings-small-en-50d

License

MIT thegreatbey

Keywords

pdf

FAQs

Package last updated on 04 Jul 2025

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