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.pdf

For 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.

More about glu

Go API

If you want to build your own tools or integrate PDF generation into a Go application, the Go library gives you direct access to all the typesetting primitives — fonts, paragraphs, pages, nodes.

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