How to Install Firecrawl pdf‑inspector: 5 Methods for Python, Node.js, Rust, WebAssembly, and CLI

Firecrawl pdf‑inspector can be installed via pip, npm, cargo, or as a command‑line tool, with each environment shipping native bindings to the same Rust core library.

Firecrawl pdf‑inspector is a fast Rust library for extracting structured Markdown and detecting PDF types. Whether you need Python bindings for data pipelines, Node.js for serverless functions, or a standalone CLI for batch processing, this guide covers every installation path with the exact commands and entry points used in the firecrawl/pdf‑inspector source code.

Python Installation

Install pdf‑inspector from PyPI with a single command:

pip install pdf-inspector

Import the module and call process_pdf or process_pdf_with_ocr:

import pdf_inspector

# Fast extraction for text‑based PDFs

result = pdf_inspector.process_pdf("report.pdf")
print(result.pdf_type)   # "text_based"

print(result.markdown)   # Structured Markdown output

# OCR‑enabled extraction for scanned documents

ocr = pdf_inspector.process_pdf_with_ocr("scanned.pdf")
print(ocr.pages_routed_to_ocr)

The Python bindings bundle OCR dependencies automatically. Full API reference: [docs/python.md](https://github.com/firecrawl/pdf-inspector/blob/main/docs/python.md).

Node.js Installation

Install the N‑API package for server or desktop applications:

npm install @firecrawl/pdf-inspector

Use processPdf or processPdfWithOcr after reading the file into a buffer:

import { readFileSync } from "fs";
import { processPdf, processPdfWithOcr } from "@firecrawl/pdf-inspector";

const pdf = readFileSync("report.pdf");
const result = processPdf(pdf);
console.log(result.pdfType);      // "TextBased"
console.log(result.markdown);

const ocr = await processPdfWithOcr(pdf);
console.log(ocr.pagesRoutedToOcr);

The Node.js bindings also include OCR runtime automatically. See [napi/README.md](https://github.com/firecrawl/pdf-inspector/blob/main/napi/README.md) for complete documentation.

WebAssembly (Browser) Installation

For client‑side PDF processing, install the WASM build:

npm install @firecrawl/pdf-inspector-wasm

Initialize the module before calling processPdf:

import init, { processPdf } from "@firecrawl/pdf-inspector-wasm";

await init();
const result = processPdf(pdfBytes);

Detailed browser integration: [wasm/README.md](https://github.com/firecrawl/pdf-inspector/blob/main/wasm/README.md).

Rust Installation

Add the crate to your Cargo.toml:

cargo add pdf-inspector

Or manually specify the dependency:

[dependencies]
pdf-inspector = "1"

Call process_pdf from src/lib.rs:

use pdf_inspector::process_pdf;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let result = process_pdf("report.pdf")?;
    println!("Type: {:?}", result.pdf_type);
    if let Some(md) = result.markdown {
        println!("{}", md);
    }
    Ok(())
}

The Rust API exposes the full public interface: process_pdf, process_pdf_with_ocr, detect_pdf, classify_pdf, and more. Reference: [docs/rust-api.md](https://github.com/firecrawl/pdf-inspector/blob/main/docs/rust-api.md).

CLI Installation

Install the command‑line tools with Cargo:

cargo install pdf-inspector

Enable OCR support with the feature flag:

cargo install pdf-inspector --features ocr

Two binaries are available, defined in [src/bin/pdf2md.rs](https://github.com/firecrawl/pdf-inspector/blob/main/src/bin/pdf2md.rs) and [src/bin/detect_pdf.rs](https://github.com/firecrawl/pdf-inspector/blob/main/src/bin/detect_pdf.rs):


# Convert PDF to Markdown

pdf2md report.pdf

# JSON output for piping to other tools

pdf2md report.pdf --json

# Classify PDF type without extraction

detect-pdf report.pdf

OCR Support Across Platforms

OCR requires PDFium for rendering and ONNX Runtime for the PP‑OCR model. Platform behavior differs:

  • Python and Node.js: OCR runtime bundled automatically; no additional setup needed.
  • Rust and CLI: Enable OCR only when building with --features ocr.

The core OCR implementation lives in src/vision/ and is invoked on demand for pages routed to OCR processing.

How the Core Library Works

All installation paths ultimately call into [src/lib.rs](https://github.com/firecrawl/pdf-inspector/blob/main/src/lib.rs), which implements a single‑document‑load architecture:

  1. PDF parsed once into a reusable structure.
  2. Detector ([src/detector.rs](https://github.com/firecrawl/pdf-inspector/blob/main/src/detector.rs)) classifies the document type.
  3. Extractor (src/extractor/) pulls text with font and layout data.
  4. Table detector (src/tables/) identifies tabular regions.
  5. Markdown converter (src/markdown/) produces structured output.

This design avoids redundant parsing and keeps extraction fast across all language bindings.

Summary

  • Python: pip install pdf-inspector → import pdf_inspector
  • Node.js: npm install @firecrawl/pdf-inspector → processPdf, processPdfWithOcr
  • WebAssembly: npm install @firecrawl/pdf-inspector-wasm → await init() then processPdf
  • Rust: cargo add pdf-inspector → use pdf_inspector::process_pdf
  • CLI: cargo install pdf-inspector → pdf2md and detect-pdf binaries

All paths share the same Rust core in src/lib.rs with optional OCR via feature flags or bundled runtimes.

Frequently Asked Questions

Does pdf‑inspector require Rust to be installed for Python or Node.js?

No. The Python and Node.js packages ship precompiled native wheels and N‑API modules. You only need Rust installed if building from source or using the CLI via cargo install.

What is the difference between process_pdf and process_pdf_with_ocr?

process_pdf performs fast text extraction without rendering, suitable for text‑based PDFs. process_pdf_with_ocr analyzes each page and routes scanned or image‑heavy pages through OCR (PDFium + ONNX Runtime), returning results with pages_routed_to_ocr metadata.

Can I use pdf‑inspector in a browser without a server?

Yes. The @firecrawl/pdf-inspector-wasm package runs entirely client‑side after init() initializes the WebAssembly module. No backend required.

How do I enable OCR in the Rust library or CLI?

Add the ocr feature when depending or installing: cargo add pdf-inspector --features ocr or cargo install pdf-inspector --features ocr. The Python and Node.js bindings include OCR by default without feature flags.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →