Skip to content
FossShelf
Home / Categories / For Web Developers

pdf-inspector

Rust-powered PDF parser with smart OCR routing for AI pipelines

Replaces Adobe Pdf Extract Api, Llamaparse Llamaindex, Google Document Ai, Amazon Textract, Reducto

20.05K starsMITreviewed 1 Sept 2026last commit 16 Nov 2026
Screenshot of pdf-inspector

Who it's for

AI engineers building RAG systems or LLM document pipelines

pdf-inspector converts reports, research papers, and financial documents to clean, position-aware Markdown in under 200ms per document. The structured output preserves tables and headings, which reduces hallucinations in downstream LLM prompts and improves chunk quality for vector embeddings.

Your corpus is primarily scanned documents or image-heavy PDFs. Without the OCR runtime configured, pdf-inspector returns no Markdown for those documents.

Backend developers routing PDFs at scale

The classification API returns a PDF type and confidence score in 10-50ms, enabling pipelines to send only scanned pages to expensive OCR services. For a corpus where 54% of documents are text-based, this routing eliminates most OCR costs without sacrificing output quality on the remaining documents.

You need a fully managed API with no infrastructure setup. pdf-inspector is a library and CLI; it does not include a hosted API endpoint.

Data engineers extracting tables from financial documents

Dual-mode table detection (rectangle-based and heuristic) recovers financial tables, footnotes, and continuation tables across pages. The TEDS score of 0.814 on the benchmark corpus is the highest among the tested local parsers. Token-splitting handles consolidated numeric values common in financial filings.

Your financial documents are scanned PDFs without embedded text. The OCR runtime must be separately configured for those cases.

Web developers embedding PDF parsing in browser applications

The WebAssembly build runs the same Rust parser in browsers and Web Workers with no server round trip. Install via @firecrawl/pdf-inspector-wasm, call processPdf() with a Uint8Array, and get classification and Markdown output entirely client-side. PDF bytes never leave the user's browser tab.

Your users will upload scanned or image-heavy PDFs. The WASM build is pure extraction with no OCR capability.

The problem

Processing PDFs at scale has two expensive problems: OCR and output quality. Most document extraction services route every PDF through OCR regardless of whether it is actually scanned, because classification is a separate step most pipelines skip. For the roughly 54% of PDFs that are already text-based (reports, research papers, invoices, legal filings), this adds seconds of latency and unnecessary cost per document. Output quality is the second problem. Raw PDF text extraction loses reading order, garbles multi-column layouts, misses tables, and fails on PDFs with CID-encoded fonts or complex formatting. The result is Markdown that needs extensive cleaning before it is usable in an LLM prompt or RAG index. Most open source parsers excel at either speed or output quality, but not both.

How it works

Smart PDF classification

Detects whether a PDF is TextBased, Scanned, ImageBased, or Mixed by sampling content streams without a full document load. Returns a confidence score (0.0-1.0) and per-page OCR routing flags in 10-50ms, enabling downstream pipelines to skip OCR entirely for native-text documents.

Structured Markdown output with reading order

Reconstructs multi-column and newspaper layouts from positioned text, preserving logical reading order across the page. Output includes headings (H1-H4 via font size ratios), bullet and numbered lists, code blocks (monospace font detection), tables, bold/italic formatting, URL links, and page break markers.

Dual-mode table detection

Combines rectangle-based detection from PDF drawing operations with heuristic detection from text alignment. Handles financial tables with consolidated numeric values, footnotes, and continuation tables that span multiple pages. Benchmark table score: 0.814 TEDS on 200 real documents, the highest among the tested local parsers.

Selective OCR with per-page routing

Routes only pages that lack text operators to OCR rather than processing the whole document. Native Python and Node packages include the OCR integration using PP-OCRv6 Small locally. PDFium and ONNX Runtime are loaded only when a page is actually routed to OCR, keeping the default build lightweight.

npm, PyPI, crates.io, and CLI packages

The same Rust processing core is exposed through Node.js (npm, with TypeScript definitions), Python (PyPI), Rust (crates.io), and a bundled CLI. Every interface calls the same pipeline with the same output, so switching languages requires no retraining. The npm package includes the bundled pdf-inspector CLI.

Browser WebAssembly support

The Rust core compiles to WebAssembly and runs in browsers and Web Workers with no server round trip. Documents are processed locally using embedded CMaps, so PDF bytes never leave the browser tab. Install via the @firecrawl/pdf-inspector-wasm package on npm.

Features

  • Smart PDF classification
  • Structured Markdown output with reading order
  • Dual-mode table detection
  • Selective OCR with per-page routing
  • npm, PyPI, crates.io, and CLI packages
  • Browser WebAssembly support

How to install

Setup is available through npm, PyPI, and crates.io for Node.js, Python, and Rust respectively.

npm install @firecrawl/pdf-inspector
pip install pdf-inspector
cargo add pdf-inspector

Recommended for this setup

Strengths

  • Fastest local parser in the opendataloader benchmark: On 200 real PDFs, pdf-inspector completed the full corpus in 0.47s (median of 5 runs), compared to LiteParse at 0.75s, PyMuPDF4LLM at 17.1s, and MarkItDown at 16.2s. The Rust core loads each document once and shares parsed state across detection and extraction stages, avoiding redundant I/O.
  • MIT license with no per-page billing: The MIT license allows commercial use, modification, and redistribution without restriction. Running locally means there is no per-page fee or API rate limit, which changes the economics of PDF processing at scale compared to Adobe PDF Extract API, Google Document AI, or Amazon Textract.
  • Classifies 300-page PDFs in milliseconds: The classifier samples content streams without a full document load, detecting PDF type on even 300-page documents in milliseconds. The result includes a per-page list of pages needing OCR, enabling selective routing rather than all-or-nothing OCR decisions on mixed documents.
  • Polyglot bindings sharing one Rust core: Node.js, Python, Rust, and browser environments all call the same underlying Rust pipeline. No binding-specific behavior differences to debug. TypeScript definitions are included in the npm package. The browser WASM build runs the same core with no server dependency.

Trade-offs

  • OCR requires separately installed runtime dependencies: Selective OCR is opt-in and requires PDFium and ONNX Runtime to be installed separately (platform-specific downloads, documented in the OCR runtime setup guide). The default build is pure extraction with no OCR capability. For purely scanned PDFs, the tool must be paired with an OCR service or the optional OCR feature.
  • No text output for scanned PDFs without OCR configured: PDF forms, image-based PDFs, and fully scanned documents produce no Markdown output without the OCR runtime enabled. Teams processing high-OCR corpora will need to configure the external dependencies or route those documents to a managed API like Reducto.
  • Benchmark limited to local, non-model-based parsers: The published benchmark covers only local engines without model-based PDF parsing, with OCR disabled. Scores are not directly comparable to managed services like LlamaParse or Adobe PDF Extract API that use LLM-based extraction. For scanned or image-heavy corpora, managed services may produce higher output quality.

Tech stack

Languages
Rust, Python, HTML, JavaScript
Frameworks
—
Databases
—
Tooling
Node.js

FAQ

Does pdf-inspector handle scanned PDFs?

Yes, with the OCR integration enabled. The default build is pure extraction for native-text PDFs. Native Python and Node packages include selective OCR using PP-OCRv6 Small locally, but PDFium and ONNX Runtime must be installed separately. The CLI and Rust crate opt into OCR at build time via a feature flag. For fully scanned corpora, a managed OCR service may be simpler to set up.

How does pdf-inspector compare to LlamaParse for text-based PDFs?

pdf-inspector runs locally in under 200ms per document with no API call required for text-based PDFs, while LlamaParse is a managed API that routes all documents through its hosted service. For native-text PDFs (reports, papers, invoices), pdf-inspector eliminates the API latency, network cost, and per-page fee. LlamaParse may still be preferred for scanned or complex documents where its model-based extraction produces better results.

What languages and runtimes does pdf-inspector support?

pdf-inspector ships bindings for Node.js (via npm, with TypeScript definitions), Python (via PyPI), and Rust (via crates.io). A bundled CLI is included with the npm package. A separate WebAssembly package (@firecrawl/pdf-inspector-wasm) runs the same parser in browsers and Web Workers with no server dependency.

Is pdf-inspector free to use commercially?

Yes. The MIT license allows commercial use, modification, and redistribution without restriction. There are no per-page fees or rate limits when running locally. The only cost is your own infrastructure.

How accurate is the PDF-to-Markdown conversion?

On the opendataloader-bench corpus of 200 PDFs (results refreshed July 31, 2026), pdf-inspector scored 0.875 overall, 0.915 on reading order, and 0.814 on table structure, the highest scores among local parsers tested without OCR. These scores apply to native-text PDFs; scanned and image-based PDFs require the OCR integration to produce any Markdown output.

Similar tools

More in Web Developers