Skip to main content
Image

r/golang



Build your online store and start selling today. No tech skills needed.
media poster


gpdf — Zero-dependency PDF generation library for Go, 10-30x faster than alternatives
gpdf — Zero-dependency PDF generation library for Go, 10-30x faster than alternatives
show & tell

Hey r/golang, I've been building gpdf, a PDF generation library written in pure Go with zero external dependencies.

The problem

gofpdf is archived, maroto's layout is limited, and most serious solutions end up wrapping Chromium (hello 300MB binary and slow cold starts) or require commercial licensing. I wanted something fast, dependency-free, and with a real layout engine that treats CJK text as a first-class citizen.

What it does

  • Full layout engine — Bootstrap-style 12-column grid system

  • Declarative Builder API — chainable, no XML/JSON templates needed

  • TrueType font embedding with full Unicode / CJK support

  • Images, tables, headers/footers, page numbering

  • Flexible units (pt / mm / cm / in / em / %)

What makes it different

  • Zero dependencies — stdlib only, no CGo, no wrappers. go get and you're done

  • Fast — 10–30x faster than comparable libraries in benchmarks. A typical invoice generates in under 1ms

  • CJK-first — Japanese, Chinese, Korean text just works. Most Go PDF libs treat this as an afterthought

Quick example

doc := gpdf.New(gpdf.WithPageSize(gpdf.A4))
doc.Page(func(p *gpdf.PageBuilder) {
    p.Row(func(r *gpdf.RowBuilder) {
        r.Col(6, func(c *gpdf.ColBuilder) {
            c.Text("Invoice #1234", text.Bold())
        })
        r.Col(6, func(c *gpdf.ColBuilder) {
            c.Text("2026-03-22", text.AlignRight())
        })
    })
})
buf, _ := doc.Generate()
os.WriteFile("invoice.pdf", buf, 0644)

Repo: github.com/gpdf-dev/gpdf Docs: gpdf.dev

Feedback and contributions welcome — especially interested in what layout features you'd want most.