npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@localmode/pdfjs

v1.0.2

Published

PDF text extraction for @localmode using PDF.js

Readme

@localmode/pdfjs

PDF text extraction for local-first document processing. Uses PDF.js for efficient browser-based PDF parsing.

npm license

Installation

pnpm install @localmode/pdfjs @localmode/core

Quick Start

import { extractPDFText } from '@localmode/pdfjs';

// From a file input
const file = document.getElementById('file').files[0];
const { text, pageCount } = await extractPDFText(file);

console.log(`Extracted ${pageCount} pages`);
console.log(text);

With Document Loader

import { PDFLoader } from '@localmode/pdfjs';
import { loadDocument } from '@localmode/core';

const loader = new PDFLoader();
const { documents } = await loadDocument(loader, pdfBlob);

for (const doc of documents) {
  console.log(doc.text);
}

Split by Page

import { PDFLoader } from '@localmode/pdfjs';
import { loadDocument } from '@localmode/core';

// Each page becomes a separate document
const loader = new PDFLoader({ splitByPage: true });
const { documents } = await loadDocument(loader, pdfBlob);

console.log(`Loaded ${documents.length} pages`);

for (const doc of documents) {
  console.log(`Page ${doc.metadata.page}: ${doc.text.substring(0, 100)}...`);
}

RAG Pipeline Integration

import { PDFLoader } from '@localmode/pdfjs';
import { loadDocument, chunk, ingest, createVectorDB } from '@localmode/core';
import { transformers } from '@localmode/transformers';

// Setup
const db = await createVectorDB({ name: 'docs', dimensions: 384 });
const model = transformers.embedding('Xenova/all-MiniLM-L6-v2');
const loader = new PDFLoader({ splitByPage: true });

// Load and ingest PDF
const { documents } = await loadDocument(loader, pdfBlob);

await ingest({
  db,
  model,
  documents: documents.map((d) => ({
    text: d.text,
    metadata: d.metadata,
  })),
});

console.log('PDF ingested successfully!');

API Reference

extractPDFText(source, options?)

Extract text from a PDF file.

const { text, pageCount, pages, metadata } = await extractPDFText(pdfBlob, {
  maxPages: 10, // Limit pages
  includePageNumbers: true, // Add [Page N] headers
  pageSeparator: '\n---\n', // Between pages
  password: 'secret', // For encrypted PDFs
});

PDFLoader

DocumentLoader implementation for PDFs.

const loader = new PDFLoader({
  splitByPage: false, // Single document vs per-page
  maxPages: undefined, // All pages
  includePageNumbers: true,
  password: undefined,
});

getPDFPageCount(source)

Get page count without full extraction.

const pageCount = await getPDFPageCount(pdfBlob);

isPDF(source)

Check if a file is a PDF.

if (await isPDF(file)) {
  // Handle PDF
}

License

MIT