Skip to content

pdf-inspector

Rust library and CLI that checks whether a PDF has real text and converts it to Markdown locally.

Stars
19.8k
Forks
1.3k
Licence
MIT
Language
Rust
Last update
14 days ago
Type
Library

What it is

pdf-inspector reads PDF files and first decides whether each one is text-based or scanned, which tells you if it needs OCR (optical character recognition). For text-based PDFs it extracts the text with position information and converts it to clean Markdown without OCR. It is a Rust library with bindings for Python, Node.js, and browser WebAssembly, plus command-line tools.

  • Check whether a batch of PDFs is text-based or scanned before deciding which ones need OCR
  • Convert a text-based PDF to Markdown from the command line with pdf2md
  • Extract text with coordinates and font info for downstream analysis
  • Run selective OCR on only the pages that need it, using the Python or Node packages

Great for

  • Developers building pipelines that process many PDFs and need to route scanned ones to OCR
  • Teams converting reports, papers, invoices, or legal PDFs into Markdown locally
  • Projects that want to avoid paid OCR services for text-based documents
  • Browser apps that need PDF text extraction without a server round trip

Not ideal for

  • People who only need a one-off conversion and do not want to install a toolchain, since no prebuilt binaries are listed for the latest release
  • Users with mostly scanned PDFs who want OCR as the main feature, because OCR requires separately installed PDFium and ONNX Runtime libraries
  • Anyone who needs guaranteed output on unusual layouts, since the README benchmark is a single corpus evaluation
Step-by-step guide: how to use pdf-inspectorInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Rust toolchain (for cargo install) · Python (for pip install) · Node.js (for npm install)

    Python package

    pip install pdf-inspector

    Node.js package

    npm install @firecrawl/pdf-inspector

    Rust CLI

    cargo install pdf-inspector
  2. 2

    Run it

    • Install the package for your language or the Rust CLI using the commands above
    • Run pdf2md document.pdf to convert a PDF to Markdown
    • Run detect-pdf document.pdf to check whether it is text-based or scanned
    • Add --json to either command for machine-readable output
  3. 3

    Get the most out of it

    • Use --select-pages to convert only the pages you need
    • Use --compact to collapse long dot leaders and padding in token-efficient output
    • Use --items-json to get positioned text with rotation and font data
    • Build with the ocr feature and set PDFIUM_LIB_PATH and ORT_DYLIB_PATH to enable selective OCR from the CLI

Downloads

Strengths

  • Fast local processing; the README reports text-based PDFs handled in under 200ms and a benchmark run with the fastest total time among compared local engines
  • Clear output types (TextBased, Scanned, ImageBased, Mixed) with a confidence score and per-page OCR routing
  • Available as a Rust crate, Python and Node packages, a browser WebAssembly build, and CLI tools under the MIT license

Trade-offs

  • Requires Rust tooling for the CLI and Rust library; the latest release lists no binaries
  • Selective OCR needs extra external libraries (PDFium and ONNX Runtime) installed separately
  • The benchmark is produced by the project's own team and covers only a 200-PDF corpus with OCR disabled

How it compares

ProjectStarsTypeLevelUpdatedBest for
pdf-inspector (this)19.8kLibraryintermediate14 days agoDevelopers building pipelines that process many PDFs and need to route scanned ones to OCR
markitdown193kLibrarybeginner8 days agoDevelopers building LLM or text analysis pipelines that need document text
docling70kLibrarybeginner5 days agoPython developers building retrieval or RAG pipelines over PDFs and office files
pdfplumber10.9kLibrarybeginner22 days agoPython developers pulling tables or text out of machine-generated PDFs
rich57.7kLibrarybeginner5 months agoPython developers who write command-line scripts and want clearer output
markdown-it22kLibraryintermediate13 days agoJavaScript or TypeScript developers who need to render Markdown in a Node.js or browser project

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.