v1.0.4 · 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.go
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)
}
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
gpdf
2 ms
gofpdf
15 ms
gopdf
20 ms
Maroto v2
45 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

01

What is gpdf?

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.

02

How fast is gpdf compared to alternatives?

gpdf renders a single-page document in approximately 13 microseconds — 10 to 30 times faster than gofpdf, gopdf, and Maroto v2 in benchmark comparisons.

03

Does gpdf support Japanese, Chinese, and Korean text?

Yes. gpdf embeds TrueType fonts and natively renders Japanese (JP), Chinese (ZH), and Korean (KR) — all 3 CJK scripts — without tofu (□) or mojibake.

04

Is gpdf free to use?

Yes. gpdf is fully open source under the MIT license. Free for personal and commercial use, including redistribution.

05

How do I install gpdf?

Run: go get github.com/gpdf-dev/gpdf. Requires Go 1.22 or later (tested through Go 1.26). 0 external dependencies — the library uses only the Go standard library.

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 →