pdf-inspector classifies PDFs as text-based or scanned, extracts positioned text, and converts native-text documents to Markdown. Bindings cover Python, Node.js, Rust, CLI, and browser WebAssembly.
Overview
pdf-inspector is a Rust library for inspecting PDFs, deciding whether pages need OCR, and turning text-based documents into structured Markdown. It targets pipelines that must handle many PDFs quickly without sending every file to OCR.
Classification samples content streams to label documents as text-based, scanned, image-based, or mixed, with confidence scores and per-page OCR routing. Text extraction keeps font data and coordinates, respects multi-column reading order, and flags broken encodings for fallback.
The Markdown converter infers headings, lists, tables, emphasis, links, and related layout from font and drawing information. Table detection combines rectangle-based and alignment heuristics, including financial layouts and continuations across pages.
Optional selective OCR can render only pages that lack text when using native builds with external PDFium and ONNX runtime. The same core runs in browsers via WebAssembly without uploading files to a server.
Packages ship through PyPI, npm, and crates.io, with a bundled CLI for shell workflows. The document loads once and is shared between detection and extraction to avoid duplicate parsing.
Key features
- Text-based vs scanned PDF classification
- Position-aware text extraction
- Markdown with headings and tables
- Per-page OCR routing lists
- Multi-column and RTL layout handling
- CID and Type0 font decoding
- Browser WebAssembly build
- Python, Node.js, Rust, and CLI bindings
Use cases
- Route PDFs before OCR in bulk pipelines
- Convert reports and invoices to Markdown
- Parse PDFs locally in the browser
- Extract tables from financial documents