Chapter 5. Navigation

Although you’ve spent the last three chapters talking strictly about static content, there is much more to PDF. This chapter will introduce various ways in which a PDF can gain interactivity, specifically around enabling navigation within and between documents.

Destinations

A destination defines a particular view of a document. It will always refer to a specific page of the PDF, and may optionally include a smaller subsection of the page as well as a magnification (zoom) factor.

Destinations don’t stand alone; they are the values of keys in specific dictionaries related to parts of a PDF that could cause the invocation of an associated action. For example, in the document catalog, a destination can be the value of the OpenAction key. When present, that instructs the viewer to jump to that destination immediately upon opening the document.

Note

A common use of OpenAction is to jump to the first page of actual document content, which may come after some preface material that most users will not be interested in reading.

Explicit Destinations

Since the number of things that make up a destination is small and well defined, a destination is not based on a dictionary but instead on an array, unlike the other types of common objects that you’ve encountered so far (see Example 5-1). The first element of the array is always an indirect reference to the page object to which it refers, followed by a name object describing the type of zoom, and then any additional options needed ...

Get Developing with PDF now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.