Skip to content

Destinations, Outlines and Annotations#

Named and numbered destinations#

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

These objects are created from the user and must be added to the NumDestinations and 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]", destObj.PageObjectnumber.Ref(), destObj.X, destObj.Y)

where destObj is a NumDest for example.

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.