#Browser and Bundlers
Use clawpdf/browser in bundled browser code. It exports the same API as clawpdf but pre-wires the packaged WASM URL through import.meta.url.
import { openPdf } from "clawpdf/browser";
await using pdf = await openPdf(file);
console.log(pdf.text({ maxPages: 3 }));
Custom resolution stays available:
import { createEngine } from "clawpdf/browser";
await using engine = await createEngine({
wasmUrl: "/assets/pdfium.esm.wasm",
});
#Inputs
Browser inputs:
Uint8ArrayArrayBuffer- URL string
URLBlob
Path-like strings throw PdfFormatError in browsers because there is no file system path to read.
#Custom Instantiation
Pass instantiateWasm when a runtime needs a custom WebAssembly instantiation path:
await using engine = await createEngine({
instantiateWasm(imports, receiveInstance) {
// Runtime-specific instantiation hook.
},
});