How firecrawl/pdf-inspector works
pdf-inspector classifies a PDF, extracts positioned text, analyzes layout, and produces Markdown; native entry points can optionally route only suspect pages through OCR. The principal flow is: caller submits bytes or a file, the core parses once, classification selects text/OCR behavior, extraction and layout produce structured content, and Markdown/result bindings return it. The tree and excerpts confirm the core and OCR orchestration; several lower-level call arrows are inferred only where module responsibilities and README behavior align.
Main entry points: lib.rs Document Core · types.rs Process Result · pipeline.rs OCR Pipeline · pdf2md.rs PDF CLI
Components 25
Public Interfaces
- Rust API
src/lib.rs - PDF CLI
src/bin/pdf2md.rs - Python Binding
src/python.rs - Node Binding
napi/src/lib.rs - WASM Binding
wasm/src/lib.rs
PDF Processing
- Document Core
src/lib.rs - PDF Classifier
src/detector.rs - Text Extractor
src/extractor/mod.rs - Font Decoder
src/tounicode.rs - Layout Analysis
src/markdown/analysis.rs - Table Detection
src/tables/mod.rs - Structure Tree
src/structure_tree.rs - Markdown Converter
src/markdown/mod.rs
Selective OCR
- OCR Pipeline
src/vision/pipeline.rs - OCR Routing
src/vision/routing.rs - Page Renderer
src/vision/render.rs - PDFium Backend
src/vision/pdfium.rs - OCR Engine
src/vision/oar.rs - Model Store
src/vision/models.rs
Results
- Process Result
src/types.rs
Other components
- Application Caller
- CLI User
- Browser Application
- PDF Document
- ONNX Runtime
Connections 40
- CLI User → PDF CLI: invokes
- Application Caller → Rust API: calls
- Application Caller → Python Binding: calls
- Application Caller → Node Binding: calls
- Browser Application → WASM Binding: calls
- PDF Document → PDF CLI: provides bytes
- PDF Document → Rust API: provides bytes
- PDF Document → Python Binding: provides bytes
- PDF Document → Node Binding: provides bytes
- PDF Document → WASM Binding: provides bytes
- PDF CLI → Document Core: processes PDF
- Rust API → Document Core: processes PDF
- Python Binding → Document Core: processes PDF
- Node Binding → Document Core: processes PDF
- WASM Binding → Document Core: processes PDF
- Document Core → PDF Classifier: classifies pages
- Document Core → Text Extractor: extracts text
- Text Extractor → Font Decoder: decodes fonts
- Document Core → Layout Analysis: analyzes layout
- Layout Analysis → Table Detection: detects tables
- Document Core → Structure Tree: reads structure
- Document Core → Markdown Converter: converts content
- Markdown Converter → Table Detection: formats tables
- PDF Classifier → Document Core: returns classification
- Text Extractor → Document Core: returns items
- Markdown Converter → Document Core: returns Markdown
- Document Core → Process Result: assembles result
- Document Core → OCR Pipeline: routes OCR
- OCR Pipeline → OCR Routing: runs routes
- OCR Routing → Page Renderer: renders pages
- Page Renderer → PDFium Backend: uses PDFium
- OCR Routing → OCR Engine: recognizes pages
- OCR Engine → ONNX Runtime: runs inference
- OCR Pipeline → Model Store: acquires model
- OCR Pipeline → Process Result: fuses OCR
- Process Result → PDF CLI: returns result
- Process Result → Rust API: returns result
- Process Result → Python Binding: returns result
- Process Result → Node Binding: returns result
- Process Result → WASM Binding: returns result