Files
pdf-inspector/wasm
Jase-Omeileo West 1c32e4bd69 fix(deps): bump lopdf to 0.42.0 for nesting-depth DoS (#198)
Bumps lopdf from 0.41.0 to 0.42.0 to fix RUSTSEC-2026-0187, preventing deeply nested PDFs from causing an unrecoverable stack-overflow process abort.
2026-08-03 11:08:34 -07:00
..

@firecrawl/pdf-inspector-wasm

Browser WebAssembly bindings for pdf-inspector. Classify PDFs and extract structured Markdown locally from a Uint8Array, using the same Rust core as the native Node.js, Python, and Rust packages.

Install

npm install @firecrawl/pdf-inspector-wasm

Usage

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

await init();

const response = await fetch("/annual-report.pdf");
const pdf = new Uint8Array(await response.arrayBuffer());
const result = processPdf(pdf);

console.log(result.pdfType);
console.log(result.markdown);

Pass options when you need selected pages or compact Markdown:

const result = processPdf(pdf, {
  pages: [1, 3, 5],
  profile: "compact",
  includePageMarkers: true,
});

The package also exports:

  • detectPdf(pdf, options?) for detection without extraction.
  • classifyPdf(pdf) for the lightweight result shape shared with the native Node.js API.
  • extractText(pdf) for plain text.
  • version() for the WASM package version.

Browser behavior

  • Parsing runs locally. PDF bytes are not uploaded anywhere.
  • The build is single-threaded and does not require cross-origin isolation.
  • CMaps are embedded so CJK font decoding does not depend on a filesystem.
  • Extraction is synchronous after init(). For large documents, call it from a Web Worker to keep the UI responsive.
  • Image-only documents still require a separate OCR step.

Build from source

cargo install wasm-pack --version 0.15.0 --locked
wasm-pack build wasm --target web --scope firecrawl --release

License

MIT