Channel guide

PDFluent for WASM / JavaScript

Generally availableUpdated 2026-05-14
Star on GitHub
On this page

Install

One command. The package is on npm today.

npm install @pdfluent/sdk-wasm
Threaded WASM needs cross-origin-isolation headers (Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Embedder-Policy: require-corp). The PDFluent playground is configured this way.

Smoke test

Open a PDF, print the page count. The example below is the smallest useful program — copy, paste, run.

typescript
import init, { PdfDocument } from '@pdfluent/sdk-wasm';

await init();
const bytes = new Uint8Array(await file.arrayBuffer());
const doc = PdfDocument.open(bytes);
console.log(`${doc.pageCount()} pages`);

Structured extraction (Preview)

PreviewIn WebAssembly, structured extraction returns Markdown from doc.extractMarkdown, blocks as a JSON string from doc.extractBlocks, and Docling JSON from extractDocling. Structured extraction ships as Preview: output quality is still improving and the API may change in a minor release.

  • Fast tier only; balanced is native only and never runs in WebAssembly.
  • Fast tier is the engine alone, pure Rust, no models.
  • Docling JSON: extractDocling(firstPage, pageCount, name); extractBlocks returns a JSON string.
  • Also new in 1.1.0: encryptPdf/decryptPdf, PdfDoc.addWatermark, extractImages, signPdf.

What this is good for

  • In-browser PDF processing — no server required
  • Privacy-sensitive client-side workflows
  • SaaS demos and document previews

Current limitations

This list is honest, not exhaustive. The site-wide list lives at Known limitations.

  • Threaded execution requires the page to be served with COOP/COEP headers.
  • Bundle size: the WASM binary is several MB. Pre-fetch and cache aggressively.
  • XFA rendering fidelity is improving alongside the Rust core.

Licensing

PDFluent is published under the AGPLv3 and is complete under it. A yearly commercial licence removes the obligation to publish your own source; nothing in the build differs and nothing is activated, so a lapsed licence breaks nothing you have shipped. Details on the licensing page.

Where to go next