Threads (@xiaoxiunique)
dev-toolsai-engineering
Original source

pdf-inspector — Smart PDF Classification to Avoid Unnecessary OCR

Summary

pdf-inspector by Firecrawl classifies PDFs as text-based vs scanned in 10-50ms, letting you skip expensive OCR for the ~54% of PDFs that already have extractable text layers. 6.8K stars (+1.8K in one day).

Problem:

Most pipelines send ALL PDFs to OCR services (charged per page), but over half already contain text layers that can be extracted directly — no OCR needed.

How it works:

  1. Classify PDF (text-based or scanned) in 10-50ms
  2. Text-based → extract locally to clean Markdown in 200ms
  3. Scanned → route to actual OCR service

Performance:

  • 200 documents classified + extracted in 0.47s (markitdown takes 16s)
  • Preserves: tables, multi-column layouts, heading hierarchy, code blocks
  • Pure Rust — no ML model, no external service dependency

Bindings:

  • Python
  • Node.js
  • Browser (WASM)

Why it matters:

Smart routing layer for any RAG/document pipeline. Classify first, only pay for OCR when genuinely needed. Could save ~50% on document processing costs for mixed PDF workloads.