Skip to content

Destinations, Outlines and Annotations#

Named destinations#

type NameDest struct {
    PageObjectnumber Objectnumber
    Name             String
    X                float64
    Y                float64
}

PDF named destinations are created by the user and must be added to the NameDestinations map of the PDF Object.

The pdf backend takes care of writing the destination names to the Names dictionary referenced from the PDF catalog object.

Outlines (bookmarks)#

The bookmarks are stored in a hierarchical structure:

type Outline struct {
    Children []*Outline
    Title    string
    Open     bool
    Dest     string
}

Each outline can have zero or more children. If Open is set to true, the PDF viewer shows its children by default. The dest must be constructed by the user and could look like this:

outline.Dest = fmt.Sprintf("[ %s /XYZ %f %f 0]", pageObjectnumber.Ref(), x, y)

The dest can also be a named destination. There are two examples on GitHub, one with direct destinations and one with named destinations.

Annotations#

Annotations are things added to the PDF such as hyperlinks. An annotation can be created just by filling the struct:

type Annotation struct {
    Subtype    Name
    Action     string
    Dictionary Dict
    Rect       [4]float64 // x1, y1, x2, y2
}

The sub type is the annotation type such as "Link" for a hyperlink.

The action needs to be provided by the user, for example <</Type/Action/S/URI/URI (https://boxesandglue.dev)>>

The Dictionary entry is an optional Dict. Each entry from the dictionary is added to the annotation object.

See the example on GitHub.