Skip to main content

Install

npm install @nemu-ai/pdf

Requirements

Runtime

Node 18 or newer, or Bun. The package publishes both ESM and CommonJS builds.

No extra setup

The six variable fonts and the harfbuzz font instancer are bundled in the package. Nothing else is required for fonts or weights.

Importing

The package exposes named exports for both APIs and the helpers.
import { Doc, Document, Color, Vector } from "@nemu-ai/pdf";
import type { Block, StyleProperties, ChartData } from "@nemu-ai/pdf";
Both ESM import and CommonJS require are supported.
import { Doc } from "@nemu-ai/pdf";

Math fonts (optional)

Formulas are typeset by MathJax. The default math font, termes, ships with the package, so basic LaTeX works out of the box. The other math fonts are optional installs that you add only if you want them.
npm install @mathjax/mathjax-newcm-font
A missing math font logs a warning and falls back to termes. See Formulas for the full list and how to select a font.
The heavier MathJax packages are runtime dependencies and are installed alongside the package. The library itself is around 2 MB packed, dominated by the bundled fonts.

Build your first PDF

Render a document with each API in a few lines.