These docs describe changes that aren’t released yet. For the newest release, see the released docs.
Recipes
Each recipe is a complete program to copy: what it makes, the code, how it works and what to change. Pick the one closest to the document you need, and change it from there.
Most recipes exist twice, in Rust and in TypeScript, and both write exactly the same bytes. Lamina PDF’s tests check that on every change, in Rust and in every JavaScript runtime: Node, Chromium, Firefox, WebKit, Deno, Bun and workerd. Each recipe shows the tested code, and its reference PDF is the file that code writes.
To run a Rust recipe from a checkout of Lamina PDF, use cargo run -p laminapdf --example <name>. Its header comment lists the arguments it takes, such as the font or image files it reads.
Create a PDF
Section titled “Create a PDF”- Hello, world: one page of text in a standard 14 font.
- An invoice: an embedded font, a table of line items, and tags for screen readers.
- Multilingual text: five scripts, each in its own embedded font.
- Images and vectors: paths, colour, transparency, a clip and two images.
- Links and outlines: links, an outline and page labels.
Edit a PDF
Section titled “Edit a PDF”- Generate, then edit: open a file’s bytes, change its metadata and save incrementally.
Read a PDF
Section titled “Read a PDF”- Extract text for an LLM: Markdown, JSON with boxes, and chunks for retrieval, in TypeScript and Rust.
Meet a standard
Section titled “Meet a standard”- A PDF/UA report: an accessible report a screen reader can follow.
- A PDF/A archive: a letter for long-term archiving.
- A PDF/A-3 invoice with XML: an invoice with its data attached.
Run it in production (TypeScript)
Section titled “Run it in production (TypeScript)”- A 100-page report: the case Lamina PDF times in every runtime.
- Open someone else’s file: a password and tighter limits, with the outcome as a value.
- Save in a Web Worker: progress and cancelling, off the main thread.
- A Cloudflare Worker: a PDF per request.
Next: Hello, world, the smallest PDF Lamina PDF writes.