Roses are red
Violets are blue
I create my PDF
With boxes and glue
Boxes and Glue
Boxes and glue is a family of tools and libraries for creating PDF documents. Everything is written in Go, built on the typesetting algorithms from TeX, and designed to handle the world’s scripts — from Latin to Arabic to CJK.
Documents are created in milliseconds, not seconds. The line breaking algorithm finds the optimum layout for each paragraph, hyphenation works across languages, and the output can meet accessibility standards like PDF/UA.
glu — Markdown to PDF
glu is the easiest way to get started. Write your content in Markdown, and glu turns it into a properly typeset PDF:
glu document.md # → document.pdfFor simple documents, that’s all you need — glu ships with sensible defaults for fonts, page size, and styling. When you need more control, there’s YAML frontmatter for metadata, custom CSS for styling, embedded Lua for calculations and dynamic content, and a callback system for things like page decorations and headers.
bagme — HTML/CSS to PDF in Go
bagme is for Go developers who want to generate PDF from HTML and CSS without learning the typesetting internals. Write your content as HTML, style it with CSS, and bagme handles line breaking, pagination, and optional PDF/UA accessibility tagging.
d, err := document.New("output.pdf", document.WithPDFUA())
d.RenderPages(`<h1>Hello</h1><p>Content goes here.</p>`)Go API — Full control
If you want to build your own tools or need full control over every typesetting primitive — fonts, paragraphs, pages, nodes — the Go library gives you direct access to the boxes and glue engine.
See the getting started guide for the Go API.
Hobby — SVG vector graphics
Hobby creates SVG vector graphics from Lua scripts. It implements the Hobby-Knuth smooth curve algorithm from MetaPost — you specify the points, and Hobby finds beautiful curves through them. Useful for diagrams, illustrations, and anything that needs precise curves.
Building blocks
Under the hood, boxes and glue is assembled from specialized libraries that are each usable on their own:
| Library | Description |
|---|---|
| textshape | Pure Go text shaping engine (a HarfBuzz port) — handles ligatures, kerning, variable fonts, and complex scripts |
| baseline-pdf | Low-level PDF writer — pure Go with minimal dependencies |