PDFium WebAssembly bindings

PDFium WASM, zero deps

Small ESM bindings for PDF text extraction, page rendering, and PNG fallback images in Node and browsers.

Get started GitHub
npm install clawpdf
Text extractionPage renderingPNG fallbackBrowser exportNo native canvas

#ClawPDF

ClawPDF is a small PDFium WebAssembly wrapper for Node and browsers. It loads PDF input, extracts text, renders pages, and produces PNG fallback images without pulling in native canvas packages, postinstall scripts, or runtime dependencies.

It is built for OpenClaw's fallback PDF path: extract text first, render selected pages only when text is too short, and keep image work inside predictable page, pixel, and dimension budgets.

#Install

bash
npm install clawpdf

ESM-only. Node 20+ is supported.

#Quick Example

ts
import { writeFile } from "node:fs/promises";
import { openPdf } from "clawpdf";

await using pdf = await openPdf("report.pdf");

console.log(pdf.pageCount);
console.log(pdf.text({ maxPages: 5 }));

const png = await pdf.page(1).png({ dpi: 144, forms: true });
await writeFile("page-1.png", png);

For server code, keep one PdfEngine alive and reuse it. The top-level extractPdf(...) helper also shares a default engine when no engine option is provided.

#Feature Map