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

sigocr

v0.1.2

Published

Fast PDF text extraction with paragraph layout and bounding regions.

Readme

sigocr

Fast PDF text extraction with paragraph layout and bounding regions.

Install

pnpm add sigocr

Usage

import { sigocr } from "sigocr";

// Extract structured text from a PDF (returns null if scanned/no embedded text)
const doc = await sigocr.pdf("/path/to/file.pdf");
// -> Document | null

// Extract from a buffer
const doc = await sigocr.buffer(pdfBuffer);

// Check if a PDF has embedded text (fast, doesn't extract)
const has = await sigocr.hasText("/path/to/file.pdf");
// -> boolean

Batch extraction

Extract many files in a single native call. Each file uses internal page-chunk parallelism via Rayon.

const docs = await sigocr.files([
  "/uploads/contract.pdf",
  "/uploads/invoice.pdf",
  "/uploads/report.pdf",
]);
// -> (Document | null)[]

Output shape

The output shape:

interface Document {
  content: string;                    // full text in reading order
  pages: Page[];
  paragraphs: Paragraph[];
  tables: Table[];
}

interface Paragraph {
  content: string;
  role?: string;                      // "title" | "sectionHeading" | "pageHeader" | "pageFooter" | "pageNumber"
  spans: Span[];                      // character offset + length into Document.content
  boundingRegions: BoundingRegion[];  // page number + polygon in points
}

Benchmarks

Measured on Apple M3 Pro, Node.js v24.

Structured extraction (with positions) - 200-page PDF

| Library | Mean | ms/page | vs sigocr | |---------|------|---------|-----------| | sigocr (native) | 16.5ms | 0.08 | 1x | | pdf.js-extract (JS) | 71.0ms | 0.36 | 4.3x slower | | pdf2json (JS) | 280ms | 1.40 | 17x slower |

Plain text extraction (no positions) - 200-page PDF

| Library | Mean | ms/page | |---------|------|---------| | pdf-parse (JS) | 51.6ms | 0.26 | | unpdf (JS) | 63.9ms | 0.32 |

Batch extraction - 100 x 3-page PDFs

| Library | Mean | vs sigocr | |---------|------|-----------| | sigocr.files (native batch) | 17.2ms | 1x | | sigocr.pdf (sequential loop) | 97.3ms | 5.7x slower | | pdf.js-extract (sequential loop) | 134.0ms | 7.8x slower |

hasText detection

| | Mean | |---|------| | sigocr hasTextBuffer | 1.7ms |

sigocr is 4.3x faster than pdf.js-extract and 17x faster than pdf2json while producing richer output: grouped paragraphs with roles, bounding regions, and document-level spans. pdf.js-extract gives raw text items that still need assembly. sigocr is also 3.1x faster than plain-text-only extractors despite doing strictly more work. Batch extraction distributes files across cores via Rayon - 100 PDFs in 17ms.

Run benchmarks yourself:

pnpm bench

How it works

  • null for scanned PDFs: No OCR engine - this library only handles embedded text
  • Pure Rust, no C deps: Uses pdf_oxide for character-level extraction. No PDFium/MuPDF binaries to ship. ~1 MB package
  • Parallel page chunks: Large PDFs are split into chunks processed in parallel via Rayon, each opening its own PDF instance
  • Paragraph roles via heuristics: Font size for heading detection, page position for header/footer/page number
  • hasText() fast path: Check if a PDF has embedded text without full extraction. Checks first 3 pages only
  • UTF-16 span offsets: Span offsets and lengths are in JavaScript string units for direct use with String.slice()