pdf-inspector
github.com/firecrawl/pdf-inspector- Category
- Developer Tools
- Rank
- No. 331Tools index
- Pricing
- Open Source
- Type
- TOOL
- Use case
- Data Processing
- Interfaces
- CLI
- Builder
- @nickscamara_
- GitHub
- 20.1k stars
- Latest release
- v1.27.0
- Date
About
A Rust library for PDF inspection, classification, and text extraction. It detects whether a PDF is text-based or scanned so callers can make smart routing decisions, extracts text with position awareness, and converts documents to clean Markdown without OCR, with selective OCR available to native Rust and CLI consumers. Bindings are provided for Python and Node.
What it does
pdf-inspector reads a PDF's internal drawing instructions to decide, page by page, whether real text is present or whether the page is only a picture of text. Pages with text become Markdown locally, with headings rebuilt from font sizes, tables from drawn rules or column alignment, and reading order recovered across multi-column layouts. Pages that fail the check are flagged with a reason, such as an invisible text layer over a scan or letters drawn as vector outlines, so a pipeline can send only those pages to optical character recognition (OCR). The core is Rust, with Python, Node and in-browser WebAssembly packages.
Why it's ranked here
The case rests on one narrow, useful idea done carefully: stop paying for OCR on pages that never needed it. The project publishes a head-to-head on a public 200-PDF corpus where it posts the top overall, reading-order and table results among local non-model parsers, plus the fastest full run, under half a second against 16 to 17 seconds for MarkItDown and PyMuPDF4LLM. Firecrawl ran that comparison itself, but it published the per-document predictions and a harness to rerun it. It is MIT licensed, ships to crates.io, PyPI and npm from one synchronized version, and tells callers why each page needs OCR rather than giving a bare yes or no.
What's good
Detection is cheap by design. By default it samples eight evenly spread pages and counts text and image drawing operators without extracting anything, and the code explains why early exit is off: an image-only cover would misclassify an annual report. OCR is genuinely opt-in. The default Rust and browser builds carry no inference code, and the Python and Node packages load PDFium, ONNX Runtime and the roughly 31 MB model set only when a page is actually routed to OCR. Offline mode with a pre-filled model folder is documented for every language. Small details show care, such as passwords being redacted from debug output.
Tradeoffs
The published benchmark is the vendor's own, and the README labels the tested build 0.2.6 while the package manifests declare 1.25.2, so it is unclear which release those numbers describe. Headings came in slightly behind LiteParse in the same table. Classification samples pages, so a long, partly scanned file is judged on eight pages unless the caller asks for a full scan. The complete OCR path is tested end to end only on Linux x64; the project calls macOS and Windows OCR a preview, and Intel Macs need a custom ONNX Runtime build. OCR also requires two separately installed native libraries.
How to use it well
Put it at the front of an ingestion pipeline for reports, papers, invoices and filings that are mostly born-digital. Run detection first, convert the text pages locally, and send only the flagged page numbers to whatever OCR or hosted parser you already pay for. Switch to the full scan strategy when telling mixed files from scanned ones matters more than speed, and use offline mode with pinned model files in locked-down deployments. It is not a document-understanding model: for handwriting, heavy scans or forms, the bundled small OCR model is a fallback, and the project itself points low-confidence pages at a hosted pipeline.
Technical notes+
Cargo.toml builds a lib plus cdylib named pdf_inspector and three binaries (pdf2md, detect-pdf, dump_ops); the default feature set is empty, and the ocr feature pulls in render-pdfium, ocr-oar and model-download, with ort pinned to =2.0.0-rc.13 under load-dynamic so ONNX Runtime is resolved from ORT_DYLIB_PATH at runtime. Native targets use lopdf 0.45 with rayon; wasm32 builds disable it for single-threaded parsing and embed CMaps via include_dir. src/detector.rs defaults DetectionConfig to ScanStrategy::Sample(8), a minimum of 3 text operators per page (raised to 10 on pages with images) and a 0.6 text-page ratio, and will not count a page as text when it has vector-outline text, only Type3 fonts or an invisible text layer. src/lib.rs defines the OCR reason codes (scanned, no_text, vector_text, invisible_text_layer, suspected_garbled_text) and a hand-written Debug impl for PdfOptions that prints the password as [REDACTED]. pyproject.toml builds with maturin, abi3 for CPython 3.8 and later. docs/ocr-runtime.md pins PDFium native-v7988, ONNX Runtime 1.27.0 and the PP-OCRv6 Small artifact revision oar-ocr-v0.7.0.
Observed
- License
- MIT
- Language
- Rust core, with PyO3 Python bindings, napi-rs Node bindings and wasm-bindgen browser bindings
- Packaging
- crates.io (pdf-inspector), PyPI (pdf-inspector), npm (@firecrawl/pdf-inspector and @firecrawl/pdf-inspector-wasm)
- Interfaces
- Library (Rust, Python, Node, browser WebAssembly) and CLI (pdf2md, detect-pdf)
- Python support
- CPython 3.8 and later via abi3 wheels
- Prebuilt wheels
- Linux x86_64 and aarch64, macOS Intel and Apple Silicon, Windows x64
- OCR runtime
- Optional; PDFium and ONNX Runtime installed separately, models downloaded and checksum-verified on first routed page
- OCR platform testing
- End-to-end OCR smoke test on Linux x64 only; macOS and Windows OCR described as preview
Read from README.md, Cargo.toml, pyproject.toml, LICENSE, src/lib.rs, src/detector.rs, src/extractor/mod.rs, docs/python.md, docs/benchmarking.md, docs/ocr-runtime.md.
Similar tools
Tags
Tech Stack
Editorially curated, with community endorsements as a secondary signal. Corrections welcome.