How to Install pdf‑inspector: Complete Guide for Rust, Python, Node.js, and WebAssembly
Install pdf‑inspector via cargo install pdf‑inspector for Rust, pip install pdf‑inspector for Python, or npm install @firecrawl/pdf‑inspector for Node.js — each ships pre‑built binaries that expose the same core Rust library.
The pdf‑inspector library from firecrawl/pdf‑inspector is a Rust‑based PDF processor that converts documents to structured Markdown with position‑aware text extraction. It offers bindings for multiple languages and environments, all built from the central [src/lib.rs](https://github.com/firecrawl/pdf-inspector/blob/main/src/lib.rs) module. This guide covers every installation path with precise commands, prerequisites, and verification steps.
Install pdf‑inspector for Rust (Library + CLI)
The Rust distribution provides both reusable library components and standalone command‑line tools.
Prerequisites
- Rust toolchain installed via rustup.rs
Installation
cargo install pdf-inspector
This downloads and compiles the crate from crates.io, installing two binaries:
pdf2md— converts PDF files to Markdowndetect-pdf— classifies PDF type without full extraction
Library Usage
Add to your Cargo.toml:
[dependencies]
pdf-inspector = "0.2"
The public API entry points—including process_pdf and detect_pdf—are defined in [src/lib.rs](https://github.com/firecrawl/pdf-inspector/blob/main/src/lib.rs).
Install pdf‑inspector for Python
Python users receive pre‑built wheels with no compile step required on supported platforms.
Prerequisites
- Python ≥ 3.8
- pip (standard package manager)
Installation
pip install pdf-inspector
Wheels are built with maturin and bundle compiled Rust code plus pdf_inspector.pyi type stubs. For detailed usage, see [docs/python.md](https://github.com/firecrawl/pdf-inspector/blob/main/docs/python.md).
Build from Source (Optional)
For custom builds or unsupported platforms:
pip install maturin
git clone https://github.com/firecrawl/pdf-inspector.git
cd pdf-inspector
maturin develop --release
Quick Verification
import pdf_inspector
result = pdf_inspector.process_pdf("report.pdf")
print(result.pdf_type) # e.g., "text_based"
print(result.markdown[:200]) # preview generated Markdown
Install pdf‑inspector for Node.js
The npm package provides a native add‑on built with napi‑rs.
Prerequisites
- Node.js ≥ 14
- npm or yarn
Installation
npm install @firecrawl/pdf-inspector
The package includes pre‑built binaries for common operating systems and architectures. On unsupported platforms, the post‑install script automatically compiles the native add‑on using your local Rust toolchain.
Usage Example
import { readFileSync } from 'fs';
import { processPdf } from '@firecrawl/pdf-inspector';
const pdf = readFileSync('invoice.pdf');
const result = processPdf(pdf);
console.log(result.pdfType); // "TextBased", "Scanned", etc.
console.log(result.markdown);
For complete Node.js documentation, refer to [napi/README.md](https://github.com/firecrawl/pdf-inspector/blob/main/napi/README.md).
Install pdf‑inspector for WebAssembly (Browser)
The WebAssembly build runs entirely in the browser with no server dependencies.
Prerequisites
- npm + Node.js (for bundling)
- A WASM‑compatible loader (modern browsers support this natively)
Installation
npm install @firecrawl/pdf-inspector-wasm
The WASM build embeds all required CMaps, eliminating network requests during PDF parsing. See [wasm/README.md](https://github.com/firecrawl/pdf-inspector/blob/main/wasm/README.md) for advanced configuration.
Browser Integration
import init, { processPdf } from '@firecrawl/pdf-inspector-wasm';
await init(); // loads and initializes the WASM module
const response = await fetch('paper.pdf');
const array = new Uint8Array(await response.arrayBuffer());
const output = processPdf(array);
console.log(output.pdfType, output.markdown);
Install pdf‑inspector from Source (All Targets)
Building from source provides maximum flexibility for development or unsupported platforms.
Prerequisites
- Rust toolchain (
rustup,cargo) - Optional: Python with
pip install maturin(for Python bindings)
Build Commands
git clone https://github.com/firecrawl/pdf-inspector.git
cd pdf-inspector
cargo build --release
This compiles:
- Core library and CLI binaries (
pdf2md,detect-pdf) - Python bindings (if maturin is available)
- Node.js native add‑on infrastructure
- WebAssembly target files
The compiled artifacts appear in target/release/.
CLI Quick Reference
After any Rust‑based installation, these commands are immediately available:
| Command | Purpose | Example |
|---|---|---|
pdf2md |
Convert PDF to Markdown | pdf2md my_file.pdf → creates my_file.md |
detect-pdf |
Classify PDF type only | detect-pdf my_file.pdf → JSON output |
The pdf2md driver is implemented in [src/bin/pdf2md.rs](https://github.com/firecrawl/pdf-inspector/blob/main/src/bin/pdf2md.rs).
Architecture Overview
Understanding the internal structure helps troubleshoot installation issues and optimize usage:
PDF bytes
│
├─► detector (src/detector.rs) → PdfType classification
│
└─► extractor (src/extractor/)
├─ fonts, content_stream, xobjects, links, layout
│
├─► tables → Markdown tables
│
└─► markdown (src/markdown/) → final output
All language bindings expose this same pipeline. The modular design allows selective use—for example, fast classification via detect_pdf without full extraction overhead.
Summary
cargo install pdf-inspector— Rust CLI tools and library cratepip install pdf-inspector— Python wheels with pre‑built binariesnpm install @firecrawl/pdf-inspector— Node.js native add‑onnpm install @firecrawl/pdf-inspector-wasm— Browser WebAssembly package- Source build —
git clone+cargo build --releasefor full control
Each distribution shares the core [src/lib.rs](https://github.com/firecrawl/pdf-inspector/blob/main/src/lib.rs) implementation, ensuring consistent PDF type detection, position‑aware extraction, and Markdown generation across all environments.
Frequently Asked Questions
Do I need Rust installed to use pdf‑inspector in Python or Node.js?
No. Pre‑built binaries are provided for Python (via pip) and Node.js (via npm) on common platforms. Rust is only required if you build from source or your platform lacks a pre‑compiled wheel/add‑on.
Can I install pdf‑inspector on Windows?
Yes. All installation methods support Windows: cargo install works with Windows Rust toolchains; Python wheels include Windows builds; the npm package provides Windows native add‑ons; and WebAssembly runs in any modern browser.
How do I verify my installation succeeded?
Run the appropriate quick check for your environment:
- Rust:
pdf2md --versionorcargo run --release --bin pdf2md - Python:
python -c "import pdf_inspector; print(pdf_inspector.__version__)" - Node.js:
node -e "console.log(require('@firecrawl/pdf-inspector'))" - WASM: Import the module in a browser console and confirm
init()resolves
What if the npm post‑install script fails to compile?
Ensure your Rust toolchain is installed and accessible in your PATH. The post‑install fallback requires cargo to build the native add‑on for unsupported architectures. Alternatively, use the WebAssembly package which requires no native compilation.
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:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →