PDFluent compiles to WASM. Process PDFs client-side without uploading files to a server.
// Install: npm install pdfluent-wasm
import init, { PdfluentSdk } from 'pdfluent-wasm';
async function renderFirstPage(file) {
await init(); // loads pdfluent_bg.wasm (~6 MB uncompressed, ~2 MB Brotli-compressed; cached after first load)
const sdk = new PdfluentSdk();
const bytes = new Uint8Array(await file.arrayBuffer());
const doc = sdk.openBytes(bytes);
const image = doc.renderPage(0, {
format: 'png',
dpi: 96,
});
const blob = new Blob([image], { type: 'image/png' });
document.getElementById('preview').src = URL.createObjectURL(blob);
doc.free();
}Run cargo add pdfluent to get started.
PDFluent is built with wasm-pack and targets wasm32-unknown-unknown. The WASM binary is published to npm as pdfluent-wasm. Import it like any ES module. No native addons, no Node.js required in the browser.
Works in Chrome 89+, Firefox 89+, Safari 15+, and Edge 89+. All modern browsers support the WASM features PDFluent uses (bulk-memory operations, multi-value returns). No polyfills needed.
The user selects a file. The browser reads it into a Uint8Array. PDFluent processes it entirely in the browser sandbox. The PDF bytes never leave the device unless you explicitly send them.
The JavaScript bindings mirror the Rust API. openBytes(), renderPage(), getMetadata(), addAnnotation() all behave identically to their Rust counterparts. Code written for the server maps directly to the browser build.
The release build of pdfluent_bg.wasm is approximately 6 MB uncompressed and ~2 MB Brotli-compressed (~2.4 MB gzip) after wasm-opt optimization. The browser caches it after the first load. Subsequent page visits initialize in under 50 ms.
PDFluent WASM runs in Cloudflare Workers. Deploy PDF processing at the edge without managing servers. The 128 MB Worker memory limit is sufficient for most documents up to 50 MB.