New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

sigocr

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sigocr

Fast PDF text extraction with paragraph layout and bounding regions.

latest
Source
npmnpm
Version
0.1.2
Version published
Maintainers
1
Created
Source

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

LibraryMeanms/pagevs sigocr
sigocr (native)16.5ms0.081x
pdf.js-extract (JS)71.0ms0.364.3x slower
pdf2json (JS)280ms1.4017x slower

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

LibraryMeanms/page
pdf-parse (JS)51.6ms0.26
unpdf (JS)63.9ms0.32

Batch extraction - 100 x 3-page PDFs

LibraryMeanvs sigocr
sigocr.files (native batch)17.2ms1x
sigocr.pdf (sequential loop)97.3ms5.7x slower
pdf.js-extract (sequential loop)134.0ms7.8x slower

hasText detection

Mean
sigocr hasTextBuffer1.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()

Keywords

pdf

FAQs

Package last updated on 03 Mar 2026

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