pdf

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package pdf renders a printout as PDF.

It does no layout. Every box in a printout is already absolute, every string already wrapped, every barcode already encoded, so rendering is a translation of marks into drawing operators and nothing else. What the renderer decides is only what a printout deliberately leaves to it: where a baseline sits inside its leading, how a justified line distributes its slack, and what a dash pattern measures.

The rules it follows are written down in doc/render.md.

out, err := tpl.Build(rows)
err = pdf.WriteFile(out, "report.pdf")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

func Write(doc *printout.Printout, writer io.Writer, options ...Option) error

Write renders a printout to a writer.

func WriteFile

func WriteFile(doc *printout.Printout, path string, options ...Option) error

WriteFile renders a printout to a file.

The whole document is rendered before the file is touched. A render that fails -- a font file that has moved since the printout was written is the ordinary way -- leaves the previous report where it was rather than truncating it to nothing.

Types

type Option

type Option func(*config)

Option configures a render.

func Uncompressed

func Uncompressed() Option

Uncompressed leaves the content streams, fonts and images uncompressed, which makes the file readable in a text editor.

func WithProducer

func WithProducer(name string) Option

WithProducer overrides the Producer string in the document information dictionary, which defaults to the printout's engine.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL