v1.0.13 · MIT · pure Go · 0 deps

Pure Go PDFs,
no coordinates.

gpdf is an open-source, MIT-licensed PDF generation library for Go. 0 external dependencies — Go standard library only. Declare layouts on a 12-column grid, embed TrueType fonts for Japanese, Chinese, and Korean, and render a single-page document in roughly 13 µs — 10–30× faster than gofpdf, gopdf, and Maroto v2.

$go get github.com/gpdf-dev/gpdf
Read the quickstart
main.gogo run .
package main

import (
    "os"
    "github.com/gpdf-dev/gpdf/document"
    "github.com/gpdf-dev/gpdf/template"
)

func main() {
    doc := template.New(
        template.WithPageSize(document.A4),
        template.WithMargins(document.UniformEdges(document.Mm(20))),
    )

    page := doc.AddPage()
    page.AutoRow(func(r *template.RowBuilder) {
        r.Col(12, func(c *template.ColBuilder) {
            c.Text("Hello, World!", template.FontSize(24), template.Bold())
        })
    })

    data, _ := doc.Generate()
    os.WriteFile("hello.pdf", data, 0644)
}
A complete program. Run it, get hello.pdf.
01

Pure Go, 0 dependencies

Go standard library only — 0 external packages, no CGO, no C toolchain. A single binary from go build runs the same on Linux containers, AWS Lambda, and edge runners.

02

12-column grid, no coordinates

Bootstrap-inspired layout. r.Col(7) + r.Col(5) = 12. Layout decisions live in the code — not in a pixel ruler. Rows and columns nest to any depth.

03

CJK, first-class

TrueType font embedding is built in. All 3 CJK scripts — Japanese, Chinese, Korean — render as-is. No tofu (□), no mojibake, no vendor patches.

Speed in numbers

measured on a cjk invoice

1 block = 2 ms

gpdf2 ms
gofpdf15 ms
gopdf20 ms
Maroto v245 ms

Benchmark: invoice generation with Japanese text, 3 embedded TrueType font subsets, 1 logo, 1 QR code. Measured per document on Go 1.25 / Apple M2. Numbers are rounded; exact values vary per run.

Why teams ship on gpdf

built for real production pdfs

~
0 external dependencies
Go standard library only. No CGO, no C toolchain, no native modules. Reproducible builds every time.
#
12-column grid
Rows and columns that sum to 12. Familiar from Bootstrap. Nestable to any depth.
語
CJK in 3 scripts
Embed TrueType fonts. Render Japanese (JP), Chinese (ZH), and Korean (KR) without any external tooling.
>
10–30× faster
~13 µs per page on a single-page document. Benchmarked against gofpdf, gopdf, and Maroto v2.
{}
Fluent Builder API
PageBuilder → RowBuilder → ColBuilder. Functional options (WithXxx) for every configuration knob.
⌘
JSON Schema + Go Templates
Declare PDF structure as JSON, drive it with text/template, and generate thousands of documents from a single source of truth.

Frequently asked questions

answers before you ship

gpdf is a pure Go, MIT-licensed PDF generation library with 0 external dependencies. It uses a Bootstrap-inspired 12-column grid for layout and supports CJK (Japanese, Chinese, Korean) natively via TrueType font embedding.

Ship PDFs today.

MIT licensed. Free forever. Tested on Go 1.22 through 1.26. One go get away.

$go get github.com/gpdf-dev/gpdf
Full documentation