Axonpack
@axonpdf/core

Overview

@axonpdf/core: the engine as WebAssembly, for writing a binding for another framework.

The axonpdf engine compiled to WebAssembly, with a small JavaScript wrapper. It runs in Node, browsers and Web Workers. It takes a document tree as JSON plus font and image bytes, and writes the PDF in chunks as pages finish.

Most apps don't use this package directly. @axonpdf/react builds the tree from your components and drives the engine for you. Use @axonpdf/core when you write a binding for another framework.

npm install @axonpdf/core

Example

import { createEngine } from "@axonpdf/core";

const engine = await createEngine();
const chunks: Uint8Array[] = [];
const tree = {
  v: 1,
  type: "DOCUMENT",
  props: { title: "Hello" },
  children: [
    {
      type: "PAGE",
      props: { size: "A4" },
      style: { padding: 40 },
      children: [
        { type: "TEXT", props: {}, children: [{ type: "TEXT_INSTANCE", value: "Hello" }] },
      ],
    },
  ],
};
engine.render(JSON.stringify(tree), (chunk) => chunks.push(chunk));
engine.free();

Every export, method, callback and error is in the Reference.

On this page