pdf

package
v1.0.20 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 20 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{
	Compress:      true,
	SubsetFonts:   true,
	ImageEncoding: canvas.Lossless,
}

Functions

This section is empty.

Types

type Options

type Options struct {
	Compress    bool
	SubsetFonts bool
	canvas.ImageEncoding
}

type PDF

type PDF struct {
	// contains filtered or unexported fields
}

PDF is a portable document format renderer.

func New

func New(w io.Writer, width, height float64, opts *Options) *PDF

New returns a portable document format (PDF) renderer.

func (*PDF) AddAnchor added in v1.0.14

func (r *PDF) AddAnchor(name string, rect canvas.Rect)

AddAnchor adds an anchor that can be referenced by a link (see AddLink). The rectangle is the area to be referenced. If the width and height are zero and the X and Y positions are zero, it will fit the entire page. If either width/height and X/Y are zero then it will fit the page's height/width and scroll to the X/Y position. Otherwise, if the width and height are zero and X and Y are not zero, it will scroll to the position but not change it's zoom.

func (r *PDF) AddLink(uri string, rect canvas.Rect)

AddLink adds a link at the given rectangle. If the URI starts with # this will link to an anchor (set with AddAnchor).

func (*PDF) AddOutline added in v1.0.14

func (r *PDF) AddOutline(name string, level int, y float64)

AddOutline adds an outline element at the given y position. The top-level element must have level zero. If any level is missing, then higher level elements are ignored.

func (*PDF) Close

func (r *PDF) Close() error

Close finished and closes the PDF.

func (*PDF) NewPage

func (r *PDF) NewPage(width, height float64)

NewPage starts adds a new page where further rendering will be written to.

func (*PDF) RenderImage

func (r *PDF) RenderImage(img image.Image, m canvas.Matrix)

RenderImage renders an image to the canvas using a transformation matrix.

func (*PDF) RenderPath

func (r *PDF) RenderPath(path *canvas.Path, style canvas.Style, m canvas.Matrix)

RenderPath renders a path to the canvas using a style and a transformation matrix.

func (*PDF) RenderText

func (r *PDF) RenderText(text *canvas.Text, m canvas.Matrix)

RenderText renders a text object to the canvas using a transformation matrix.

func (*PDF) SetImageEncoding

func (r *PDF) SetImageEncoding(enc canvas.ImageEncoding)

SetImageEncoding sets the image encoding to Loss or Lossless.

func (*PDF) SetInfo

func (r *PDF) SetInfo(title, subject, keywords, author, creator string)

SetInfo sets the document's title, subject, keywords, author and creator.

func (*PDF) SetLang added in v1.0.10

func (r *PDF) SetLang(lang string)

SetLang sets the document's language. It must adhere the RFC 3066 specification on Language-Tag, eg. es-CL.

func (*PDF) Size

func (r *PDF) Size() (float64, float64)

Size returns the size of the canvas in millimeters.

Jump to

Keyboard shortcuts

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