Browser Setup
Install the ESM package in the browser application's dependency set:
Load the module asynchronously before creating documents. This lets the package load its WebAssembly binary in a page or module Worker.
import { createMuhammaraWasm } from "@muhammara/wasm";
var muhammara = await createMuhammaraWasm();
var writer = muhammara.createWriter();
The package is ESM-only. Browser applications should serve the bundled module
and its .wasm asset over HTTP through their bundler or static server. Do not
use synchronous CommonJS loading.
TypeScript
The package ships its own declarations and requires TypeScript 5.7 or later.
PDF bytes returned by the package, such as endPDF(), end(), and
createBlankPdf(), are typed as Uint8Array<ArrayBuffer>, so they can be passed
to new Blob([bytes]) or new Response(bytes) without a cast.
Load The WebAssembly Binary
By default the package loads muhammara-wasm.wasm from next to its own
module, and bundlers emit the file automatically. To serve it from a CDN or
supply bytes the application retrieved itself, use the locateFile or
wasmBinary options described in Load the WebAssembly Binary From a CDN or
Your Own Bytes.
Work With Bytes
Keep source PDFs, fonts, and images as bytes in application code. Inputs are
Uint8Array or ArrayBuffer; output remains owned JavaScript bytes after an
operation completes.
Continue with Byte Assets and Blob Input, then run the interactive browser examples. To display or transfer generated output, see Preview, Download, or Upload a PDF.