Chapter 6. Annotations

This chapter will go into detail on a special type of object in PDF—the annotation. Annotations are PDF objects that enable user-clickable actions as well as new types of content including 3D, video, and audio.

Introduction

The content that a user sees on a PDF page is described using a content stream of PDF graphic operators (see Content Streams for more). However, sometimes it is necessary to overlay that content with active or “hot” areas, or additional graphics. You may also want to incorporate new types of content onto your pages, such as 3D graphics or videos that cannot be described using those graphic operators. To accomplish these things, the annotation object is used.

As with page content, annotations are associated directly with a page. In any page dictionary for a page containing annotations, there has to be an Annots key whose value is an array of the annotations.

Annotation Dictionaries

Annotation objects are dictionary objects containing at least two keys: Rect and Subtype. The Rect key, of course, has a value that is a rectangle representing the page coordinates where the annotation is to be placed by the viewing application. The Subtype key has a name value that represents which one of the 27 types of annotations is being described by this particular dictionary. Many types of annotations will also have a Contents key whose value is a text string that is displayed either directly on the page or is an alternate description of the annotation’s content ...

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.