pdf-inspector is a Rust library for inspecting PDFs: it figures out whether a document is text-based, scanned, image-based, or mixed, then extracts text or converts to Markdown accordingly. It's built by Firecrawl for pipelines that process PDFs at scale and want to skip OCR for the majority of documents that don't need it. It targets backend developers, data pipeline builders, and anyone building document ingestion for RAG, search, or archival systems, with bindings for Rust, Python, Node.js, and browser WebAssembly.
Use pdf-inspector when you're building an ingestion pipeline that needs to classify PDFs before deciding how to process them, for example routing text-based reports, invoices, legal documents, or research papers to fast local extraction while sending truly scanned pages to an OCR service. It fits well when you need structured Markdown output with headings, tables, and lists preserved rather than a flat text dump, and when you care about latency (extraction runs in roughly 150ms for text-based PDFs versus seconds for OCR).
It's also a good fit if you want a single parser shared across Rust, Python, Node.js, and browser environments, since the core logic is written once and exposed through consistent bindings.
It's not the right tool if your PDFs are predominantly scanned images and you need full-document OCR as the primary path; the default builds are extraction-focused and OCR is an opt-in add-on that still requires separately installed PDFium and ONNX Runtime binaries. It also isn't a general PDF editing or generation library, it's read-only inspection and extraction.
Python:
pip install pdf-inspector
import pdf_inspector
result = pdf_inspector.process_pdf("document.pdf")
print(result.pdf_type)
print(result.markdown)
Node.js:
npm install @firecrawl/pdf-inspector
import { readFileSync } from 'fs';
import { processPdf } from '@firecrawl/pdf-inspector';
const pdf = readFileSync('document.pdf');
const result = processPdf(pdf);
console.log(result.markdown);
Browser WebAssembly:
npm install @firecrawl/pdf-inspector-wasm
Rust:
cargo add pdf-inspector
CLI:
cargo install pdf-inspector
pdf2md document.pdf
detect-pdf document.pdf --json
For OCR support in Rust/CLI, build with the ocr feature and provide PDFium and ONNX Runtime library paths:
cargo install pdf-inspector --features ocr --bin pdf2md
PDFIUM_LIB_PATH=/path/to/libpdfium ORT_DYLIB_PATH=/path/to/libonnxruntime \
pdf2md scan.pdf --ocr auto --json
Python and Node packages include the OCR pipeline natively but still need PDFium and ONNX Runtime available at runtime when a page is routed to OCR.