Authoring · Go

Generate a PDF in Go

Create PDFs programmatically from Go: pages, vector graphics, embedded and subset fonts with full Unicode shaping, justified paragraphs, tables and images. rust-pdf gives Go a fast, memory-safe core with deterministic output.

Why Go needs this

Go's PDF story is fragmented: gofpdf is archived and unipdf is commercial, so production-grade output usually means a paid dependency or a brittle wrapper.

Generation is the free foundation. Draw shapes, place shaped and kerned Unicode text, lay out wrapping paragraphs, embed JPEG and PNG images, and add links and bookmarks. Output is deterministic (the same input yields the same bytes), which makes it auditable and testable.

  • Vector graphics, embedded and subset fonts, HarfBuzz-quality Unicode shaping and kerning.
  • Wrapping and justified paragraphs, tables, images (JPEG, PNG, alpha, 16-bit).
  • Deterministic output: identical bytes for identical input, ideal for audits and tests.

Generate a PDF in Go with rust-pdf

Install the package, then call the same idiomatic API every rust-pdf binding shares. The snippet below is real Go code from the reference docs.

Go
package main

import rustpdf "github.com/rustpdf/rustpdf-go"

func main() {
	doc, _ := rustpdf.New()       // A4 by default
	defer doc.Close()

	_ = doc.AddPage()
	_ = doc.SetFillRGB(0.86, 0.20, 0.18)
	_ = doc.Rect(72, 640, 200, 120)   // x, y, width, height (points)
	_ = doc.Fill()
	_ = doc.Save("out.pdf")
}
Validated by: qpdfmutool

This is part of the free tier in Go. No license required.

Full Go reference in the documentation.

Generation in Go: FAQ

Is generating PDFs free in Go?

Yes. All basic generation (pages, graphics, fonts, text, paragraphs, images, links, bookmarks, watermarks) is free forever. You only license corporate features such as PDF/A, signatures and encryption when you ship them.

Does it support Unicode and custom fonts?

Yes. Fonts are embedded and subset with HarfBuzz-quality shaping and kerning, using Type0 fonts with ToUnicode, so non-Latin scripts render and extract correctly.

Why a Rust core for Go?

One memory-safe, high-performance Rust core is exposed to Go through a thin idiomatic binding. You get the same engine, the same features and deterministic output, without a heavy runtime.

Generate a PDF in Go

One Rust core, the same output across every language. Prototype for free, license the corporate features when you ship.