firecrawl/pdf-inspector
Fast Rust library for PDF inspection, classification, and text extraction. Intelligently detects scanned vs text-based PDFs to enable smart routing decisions.
What it solves
pdf-inspector solves the problem of expensive and slow PDF processing by providing a fast way to classify PDFs and extract their content. Many pipelines waste resources by running Optical Character Recognition (OCR) on every document, even when the PDF is already text-based. This library allows developers to quickly determine if a PDF is text-based or scanned and extract structured Markdown from text-based PDFs locally and rapidly.
How it works
The library uses a two-stage process:
- Smart Classification: It samples content streams to detect if a PDF is
TextBased,Scanned,ImageBased, orMixed. This happens in milliseconds by looking for text and image operators without loading the full document. - Text Extraction: For text-based PDFs, it performs position-aware extraction. It analyzes font sizes, X/Y coordinates, and drawing operations to identify headings, tables, lists, and multi-column layouts, which it then converts into clean Markdown.
For documents that are scanned or mixed, the library offers selective OCR, allowing users to run OCR only on the specific pages that actually need it using PP-OCRv6 Small locally.
Who it’s for
It is designed for developers building large-scale document processing pipelines, specifically those handling reports, research papers, financial documents, invoices, and legal PDFs where speed, reading order, and table structure are critical.
Highlights
- High Performance: Processes text-based PDFs locally in under 200ms.
- Multi-Language Support: Provides bindings for Rust, Python, Node.js, and Browser WebAssembly.
- Structured Output: Converts PDFs to Markdown with support for H1-H4 headings, tables (rectangle and heuristic detection), code blocks, and multi-column layouts.
- Selective OCR: Routes only necessary pages to OCR to minimize latency and cost.
- Position Awareness: Extracts text with font information and coordinates to maintain reading order.
Related
- Project
- Project
- Project
- Project
- Project