Write Go. Get a PDF.

gpdf is a PDF library for Go with no dependencies outside the standard library. Lay out pages on a 12-column grid, embed Japanese, Chinese, and Korean fonts, and render a page in about 13 µs.

$go get github.com/gpdf-dev/gpdf
How it works
invoice.go
doc := template.New(template.WithPageSize(document.A4))
page := doc.AddPage()

page.AutoRow(func(r *template.RowBuilder) {
    r.Col(6, func(c *template.ColBuilder) {
        c.Text("ACME Corporation", template.FontSize(24),
            template.Bold(), template.TextColor(navy))
    })
    r.Col(6, func(c *template.ColBuilder) {
        c.Text("INVOICE", template.FontSize(28),
            template.Bold(), template.AlignRight())
    })
})

page.AutoRow(func(r *template.RowBuilder) {
    r.Col(12, func(c *template.ColBuilder) {
        c.Table(header, items,
            template.ColumnWidths(40, 15, 20, 25),
            template.TableStripe(pdf.RGBHex(0xF5F5F5)),
        )
    })
})

data, err := doc.Generate()
invoice.pdfOpen the PDF
Invoice PDF rendered by gpdf: company header, bill-to block, striped line-item table, and totals

Pure Go, nothing else.

go.mod lists only Go itself. No cgo, no headless browser, no native binary to ship next to your service.

Layout you already know.

Rows and a 12-column grid flow onto pages. Tables split across page breaks and text wraps on its own.

Every script, embedded.

TrueType fonts are subset to the glyphs you use, so Japanese, Chinese, and Korean look the same on every server.

Benchmarks

Fast enough to render inside the request.

The same four documents built with gpdf, go-pdf/fpdf, signintech/gopdf, and maroto v2. Time and memory per document, lower is better.

Single page
One A4 page with a heading and a paragraph
gpdf
x
13 µs
fpdf
x
132 µs
gopdf
x
423 µs
maroto v2
x
237 µs
10–33× fastertime
Table (4×10)
A styled table with a header row
gpdf
x
108 µs
fpdf
x
241 µs
gopdf
x
835 µs
maroto v2
x
8,600 µs
2–80× fastertime
100 pages
The same page repeated 100 times
gpdf
x
683 µs
fpdf
x
11,700 µs
gopdf
x
8,600 µs
maroto v2
x
19,800 µs
13–29× fastertime
Complex document
Headings, tables, and mixed text on one document
gpdf
x
133 µs
fpdf
x
254 µs
gopdf
x
997 µs
maroto v2
x
10,400 µs
2–78× fastertime
Single page, memory
Allocated while building one page
gpdf
x
16 KB
fpdf
x
1,200 KB
gopdf
x
1,800 KB
maroto v2
x
61 KB
4–113× less memorymemory
100 pages, memory
Allocated while building 100 pages
gpdf
x
909 KB
fpdf
x
121,000 KB
gopdf
x
83,000 KB
maroto v2
x
4,000 KB
4–133× less memorymemory

Median of 5 runs, 100 iterations each. Apple M1, Go 1.25. The benchmark code lives in the gpdf repository.

See the benchmark code

Go-native architecture

Built in Go. Nothing else to run.

Many PDF setups for Go reach outside the language: a headless browser in a sidecar, an HTML-to-PDF service over HTTP, or a binding to a native library. Each one adds a runtime to deploy, patch, and monitor.

gpdf is written in Go from the first line. It compiles into your binary, runs wherever Go runs, and its whole dependency tree is the standard library — there is nothing extra for your security team to audit.

One go get, one binary, the same output in development and production.

Typical setup

Your Go app

HTTP call or cgo binding

Headless browser · JVM · native library

One more runtime to deploy, patch, and monitor.

gpdf

Your Go app

go get

github.com/gpdf-dev/gpdf

One binary · stdlib only · no cgo

Runs on

LinuxmacOSWindowsDockerServerless

CJK, first-class

Japanese, Chinese, and Korean, exactly as written.

Most PDF libraries treat CJK as an afterthought. gpdf was built with it from day one.

  • Embed any TrueType font; only the glyphs you use are written to the file.

  • Mix Japanese, Chinese, Korean, and Latin text in one paragraph or table.

  • No tofu (□), no mojibake, no dependence on fonts installed on the server.

Read the font guide
Japanese text rendered by gpdf with an embedded Noto Sans JP subsetA gpdf table mixing Japanese, Chinese, and Korean text

日本語 · 中文 · 한국어

More than layout.

Archiving, security, and post-processing ship in the same module — still nothing but the Go standard library.

PDF/A

PDF/A-1b and PDF/A-2b output with XMP metadata, for documents that must stay readable for decades.

AES-256 encryption

Owner and user passwords with permission control for printing, copying, and editing.

Digital signatures

PKCS#7 signatures with RFC 3161 timestamps, applied to the finished PDF.

Headers and footers

Running headers, footers, and page numbers that repeat on every page.

QR codes and barcodes

QR and Code 128 generated natively, next to PNG and JPEG images.

Merge and split

Combine PDFs or pull out page ranges without leaving Go.

And more…

Stamp overlays on existing PDFs and flatten filled AcroForm fields into static content.

Browse the examples

gpdf and the alternatives

Choosing a PDF library is more than features.

What you deploy, what you pay for, and what you have to keep patched.

gpdfCommercial Go SDKsHTML to PDF (headless browser)
LicenseMIT, free for commercial usePaid license or metered keyOpen source, but you run the browser
DependenciesGo standard library onlyVendor modulesA browser runtime in every image
DeploymentInside your Go binaryGo binary plus a license keySidecar or separate service
CJK textBuilt in, subset embeddingDepends on font setupDepends on fonts in the image
Single pageAbout 13 µsVaries by productA browser render per request

From go get to production.

Pick the entry point that fits your stack. All three run through the same rendering engine.

Install in one line

go get github.com/gpdf-dev/gpdf. Works with Go 1.22 and later.

Builder API

Fluent, type-safe Go: PageBuilder → RowBuilder → ColBuilder.

JSON schema

Describe documents as JSON and send them from any service or language.

Go templates

Drive the JSON schema with text/template — one source for thousands of documents.

Ready-made templates

Invoices, receipts, and estimates you can copy and adapt.

Runnable examples

Every example is a test that renders a real PDF, from tables to signatures.

Golden-file tests

Every example is compared byte for byte with a saved PDF before each release.

Checked for conformance

Generated files are validated against the PDF specification in CI.

Go 1.22 to 1.26

CI runs the whole suite with the race detector on every supported Go version.

FAQ

Questions before you ship

gpdf is an MIT-licensed PDF generation library written in pure Go with no external dependencies. It lays out pages on a 12-column grid and embeds TrueType fonts, including Japanese, Chinese, and Korean.

Ship your first PDF today.

One go get, then a few lines of Go.