Authoring
Generate PDFs programmatically
Last updated: 2026-06-29
Building a PDF from scratch means turning your data into a real page: text in the right font, vector shapes, images, tables and links. rust-pdf does all of that from code, the same way in every language it supports, on one shared Rust core. The authoring foundation is free, and the output is identical byte for byte across languages. This hub explains what you can build and links to a guide per language.
A free authoring foundation
Many PDF libraries put their best features behind a paywall and leave you with a thin free tier that can barely place text. rust-pdf takes the opposite approach. The entire authoring layer is free: you can lay out a full invoice, a styled report or a multi-page catalog, embed your brand fonts, draw charts as vector graphics, place photographs, and ship it to production without a license.
The foundation is built for correctness, not just for getting something onto the page. Text is shaped the way a typesetting engine shapes it, fonts are embedded so the file is self-contained, and every run is reproducible. The result is a PDF you can put in front of an auditor, a regulator or a customer with confidence.
What you can build
Every piece below is part of the free core, exposed in each language binding.
Vector graphics
Lines, rectangles, curves and fills with precise colors. Numbers are written in fixed notation, so the page geometry is exact and reproducible.
Embedded, subset fonts
Your fonts are embedded and subset automatically, so files stay small and self-contained. Text is shaped with HarfBuzz-quality Unicode shaping and kerning.
Justified paragraphs
Greedy line breaking using real shaped widths, with left, right, center and full justification. Extra space is distributed evenly between words.
Tables
Stack rows that break across pages and repeat headers automatically, measured with the same paragraph engine that lays out body text.
Images
JPEG is embedded verbatim with no re-encoding and no generation loss. PNG is supported with alpha transparency and 16-bit samples, including palette images.
Links and bookmarks
Add clickable links and an outline of bookmarks so readers can navigate a long document. Stamp watermarks across pages when you need them.
Deterministic output you can audit
rust-pdf writes no timestamps and relies on no hash-map ordering. The object graph is laid out in a stable, predictable sequence, so the same input always produces byte-for-byte identical output. If you generate the same report twice, the two files are exactly equal.
That property is more useful than it first sounds. You can pin a checksum in a test and catch any accidental change to a template. You can diff two generated files and see precisely what your data changed. You can reproduce a customer's exact document months later for an audit. It is also the basis of an internal guarantee the project keeps: the same drawing produces the same bytes whether it is run from Rust or from a language binding, which is verified on every build.
A memory-safe Rust core
PDF generation often runs on a server, turning untrusted data into documents at scale. A buffer overflow or a use-after-free in that path is a security incident.
rust-pdf is written in Rust, which rules out entire classes of memory-safety bugs at compile time. There is no manual memory management to get wrong, no dangling pointers, no data races in the document model. The language bindings are thin wrappers over the same core, so Go, PHP, Ruby and Node all inherit that safety rather than reimplementing PDF parsing and writing in each ecosystem. One core is hardened once, and every language benefits.
Generate a PDF in your language
Each guide walks through creating a document, adding a page, drawing content, and writing the file.
How to generate a PDF with rust-pdf
Create a document, add a page, embed a font, draw, and write the bytes. The free core needs no license.
# pip install rustpdf
import rustpdf
with rustpdf.Document() as doc:
f = doc.add_font_file("Roboto-Regular.ttf") # embedded & subset
doc.add_page()
doc.show_text(f, 22, 72, 760, "Quarterly report")
doc.show_text(f, 12, 72, 720, "Generated with rust-pdf")
doc.save("report.pdf") # free, no license needed
// go get github.com/rustpdf/rustpdf-go@latest
doc, _ := rustpdf.New()
defer doc.Close()
f, _ := doc.AddFontFile("Roboto-Regular.ttf")
doc.AddPage()
doc.ShowText(f, 22, 72, 760, "Quarterly report", 0)
data, _ := doc.ToBytes()
os.WriteFile("report.pdf", data, 0o644)
// npm install rustpdf
const { Document } = require("rustpdf");
const fs = require("fs");
const doc = new Document();
const f = doc.addFontFile("Roboto-Regular.ttf");
doc.addPage();
doc.showText(f, 22, 72, 760, "Quarterly report");
fs.writeFileSync("report.pdf", doc.toBytes());
# gem install rustpdf
require "rustpdf"
doc = RustPdf::Document.new
f = doc.add_font_file("Roboto-Regular.ttf")
doc.add_page
doc.show_text(f, 22, 72, 760, "Quarterly report")
File.binwrite("report.pdf", doc.to_bytes)
Generation is exposed across eight language bindings on one Rust core. Full details in the documentation.
Generation is free; corporate features are licensed
Authoring PDFs with rust-pdf costs nothing. Corporate features build on the same core and are licensed: PDF/A archiving, digital signatures and encryption are gated so the rule is identical in every language. Start free, then activate a license when you need those capabilities. See the plans on the pricing page, or read the full API in the documentation.
Generate PDF FAQ
How do I generate a PDF programmatically?
Create a document, add a page, embed a font, then draw text, vector graphics and images, and write the bytes out. With rust-pdf the same API is available in Go, PHP, Ruby and Node, all driven by one Rust core, so identical input produces identical output in every language.
Is generating PDFs with rust-pdf free?
Yes. The full authoring foundation, including vector graphics, embedded fonts, Unicode shaping, paragraphs, tables, images, links, bookmarks and watermarks, is free to use. Corporate features such as PDF/A archiving, digital signatures and encryption are licensed, and they are gated in the core so the same rule applies in every language.
Does rust-pdf produce deterministic output?
Yes. rust-pdf writes no timestamps and uses no hash-map ordering, so identical input always yields byte-for-byte identical output. This makes generated PDFs auditable and easy to test: you can diff two runs, or pin a checksum in a test, and trust that any difference reflects a real change in your data.
What kinds of text and images are supported?
Text is shaped with HarfBuzz-quality Unicode shaping and kerning, fonts are embedded and subset automatically, and paragraphs can be left, right, centered or justified. Images can be JPEG, which is embedded verbatim with no re-encoding, or PNG, including alpha transparency and 16-bit samples.
Generate PDFs in your language
One core, the same authoring output across every language. Free to generate, license the corporate features when you ship.