go · CLI + library
pretty-pdf turns a folder of Markdown into a typeset, print-ready PDF — or EPUB —
via headless Chrome. No LaTeX, no design tools, nothing to install but a binary.
go install github.com/sazardev/go-pretty-pdf/cmd/pretty-pdf@latest
How it works
01 — Write
.md, .mdx, or even bare .txt — missing frontmatter gets an id/title generated from the filename automatically.
--- id: "[1.0.0]" title: Getting Started --- # Getting Started
02 — Configure
17 built-in themes, custom paper dimensions for print-on-demand, and a cover image — all from one config file.
theme: gruvbox paper: 6x9in cover_image: cover.svg
03 — Ship
A quality audit checks for overflow, broken images, and clipped headings before you ever open the file.
$ pretty-pdf build \
--format pdf,epub
Everything a real book needs
Every feature below ships in the core binary — no plugins, no paid tier.
From clean & minimal to Gruvbox, LaTeX-style academic papers, and government letterhead.
Build both formats from the same Markdown in a single pass — no separate pipeline to maintain.
6×9in, A5, or exact mm/in dimensions — the sizes real print-on-demand services expect.
Fenced code blocks are highlighted via Chroma, with a palette matched to your theme.
Table of contents and PDF bookmarks are generated straight from your headings.
Catches overflow, broken images, low-contrast text, and clipped headings before you do.
<DeepDive>, <Warning>, <Axiom> — or register your own in Go.
watch and serve rebuild on save, with the browser refreshing instantly.
Even a stray .txt file gets folded in — auto-numbered, auto-titled, zero setup.
The CLI
The whole tool is one binary with a handful of commands — everything below works on Linux, macOS, and Windows.
pretty-pdf init my-bookScaffold a book: skeleton MDX + config.pretty-pdf buildRender a print-ready PDF (and EPUB with --format pdf,epub).pretty-pdf checkValidate source only — no Chrome needed.pretty-pdf epubBuild an EPUB 3, no Chrome required.pretty-pdf serveLive HTML preview with live reload.pretty-pdf watchRebuild the PDF on every save.pretty-pdf theme listBrowse 17 built-in themes or add your own.pretty-pdf completionShell completions for bash, zsh, fish.Themes — try one
This page is skinned with the exact same tokens as the real themes — click one, the whole site follows.
Currently previewing default — this is exactly what your book's cover, headings, and code blocks would use. Download this page's docs in this theme →
Why not LaTeX?
| LaTeX | Design app | pretty-pdf | |
|---|---|---|---|
| Plain text, git-diffable | Yes | — | Yes |
| Runs headless in CI | Yes | — | Yes |
| Learning curve | Steep | Software-specific | Just Markdown |
| Print-ready trim sizes | Manual | Manual | Built in |
| Free & open source | Yes | Usually not | MIT licensed |
Measured, not estimated
Real books rendered end-to-end: parse, validate, compose, Chrome print, and the quality audit are all inside the wall time. Reproducible on your own machine — full methodology and every size in BENCHMARKS.md.
| Source docs | Validation | EPUB | PDF pages | PDF wall time | Throughput |
|---|---|---|---|---|---|
| 100 | 30 ms | 27 ms | 121 | 0.57 s | 211 pages/s |
| 1,000 | 62 ms | 88 ms | 1,180 | 2.99 s | 394 pages/s |
| 3,000 | 142 ms | 248 ms | 3,535 | 23.02 s | 154 pages/s |
FAQ
Straight answers about how go-pretty-pdf works, what it needs, and what it can build.
No. PDFs are rendered from Markdown/MDX via headless Chrome — no LaTeX, no separate design tool, nothing to install but the binary.
Usually not. On first render, chromemgr auto-downloads a headless Chrome build if no system Chrome or --chrome-path is found. Only on linux/arm64 you must provide Chrome yourself.
Yes. The epub command builds EPUB 3 output from the same Markdown with no Chrome or Chromium required.
.md, .mdx, and even bare .txt files. Documents are ordered by their [X.Y.Z] frontmatter id, not by filename.
17 themes — from minimal and modern to Gruvbox, LaTeX-style academic, corporate, and government letterhead — plus a custom .theme.yml system and per-theme color/font overrides.
Yes. A single command (--format pdf,epub) builds both from the same Markdown in one pass — no separate pipeline.
Yes. A 3,000-document book validates in 142 ms and renders a 3,535-page PDF in ~23 s on a mid-range i5. The Go-side pipeline stays sub-second at every size — see BENCHMARKS.md for the reproducible methodology.
Yes — MIT licensed, open source, no paid tier. Every feature ships in the core binary.