Reference Interactive

Action types

1.4 §8.51.7 §12.6

All 18 action types in PDF 1.7 and the two that PDF 2.0 adds, what each does, and every place an action can be triggered.

PDF 1.4 has 13 action types; PDF 1.7 has 18. PDF 1.5 added SetOCGState, Rendition and Trans, and PDF 1.6 GoToE and GoTo3DView. PDF 2.0 adds GoToDp and RichMediaExecute and deprecates Sound and Movie.

An action is a dictionary that tells the reader to do something: /S names the type of action, and the other entries depend on the type. << /S /URI /URI (https://example.com/) >> opens a web page. Actions run when the user clicks a link, bookmark or form field, when a page or the document opens, and on other events. Interactive features in Learning shows how they fit with annotations and forms.

Actions arrived in PDF 1.1, so the five types the specifications leave unmarked carry a PDF 1.1 badge. Each row gives the type’s own entries besides S, and the table that defines them.

Action types

1.4 Table 8.341.7 Table 198

PDF 2.0 lists them in its Table 201.

TypeWhat it doesEntriesAdded
GoToGo to a destination in this document. In a link or outline item it does the same as a plain /Dest, which is shorter and works in PDF 1.0 too.D the destination: a name, a string or an array such as [7 0 R /Fit]. PDF 2.0 adds SD, a structure destination, which takes precedence over D.1.4 Table 8.35 · 1.7 Table 199PDF 1.1
GoToRGo to a destination in another PDF file.F the file. D the destination; in an explicit destination array the page is a page number, counting from 0, instead of a reference. NewWindow (PDF 1.2).1.4 Table 8.36 · 1.7 Table 200PDF 1.1
GoToEGo to a destination in a PDF embedded in this one (as an embedded file or a file attachment), or from an embedded PDF to its parent.T a target dictionary: a path of steps up to a parent (/R /P) or down to a child (/R /C). F, D, NewWindow.1.7 Table 201PDF 1.6
GoToDpGo to the start page of a document part (DPart) in this document.Dp the DPart dictionary.2.0 Table 206PDF 2.0
ThreadStart reading an article thread, optionally at a given bead.D the thread: a thread dictionary, its index in the catalog’s /Threads, or its title. B the bead. F the file, if not this one.1.4 Table 8.39 · 1.7 Table 205PDF 1.1
NamedRun a command the reader defines, such as going to the next page. See named actions.N the name of the command.1.4 Table 8.46 · 1.7 Table 212PDF 1.2
TypeWhat it doesEntriesAdded
URIResolve a URI: usually, open a web page. A relative URI is resolved against the /Base in the catalog’s /URI dictionary, or else against the document’s own location.URI the URI, in 7-bit ASCII. IsMap: if true, the click position within the link is added to the URI as ?x,y.1.4 Table 8.40 · 1.7 Table 206PDF 1.1
LaunchStart an application, or open or print a file.F the application or file. Win Windows-specific parameters: file, directory, open or print, and arguments. Mac and Unix were never defined, and PDF 2.0 deprecates all three. NewWindow (PDF 1.2).1.4 Table 8.37 · 1.7 Table 203PDF 1.1

Showing and hiding

TypeWhat it doesEntriesAdded
HideHide or show annotations by setting or clearing their Hidden flag. With the E and X triggers it can pop up a help label while the pointer is over something.T an annotation, the full name of a form field (for its widgets), or an array of these. H true to hide (the default), false to show.1.4 Table 8.44 · 1.7 Table 210PDF 1.2
SetOCGStateTurn optional content groups (layers) on or off.State names followed by the groups they apply to, read left to right: [/OFF 2 0 R /Toggle 5 0 R /ON 6 0 R]. PreserveRB (default true) keeps radio-button groups of layers consistent.1.7 Table 213PDF 1.5
TransIn a chain of actions, show the page as it is so far, using a transition effect such as a dissolve. Readers otherwise don’t redraw until the chain ends.Trans a transition dictionary.1.7 Table 215PDF 1.5

Forms and scripts

TypeWhat it doesEntriesAdded
SubmitFormSend form field names and values to a URL, usually a web server.F the URL. Fields the fields to send, or to leave out. Flags pick the format (FDF by default, or HTML form data, or, since PDF 1.4, XFDF or the whole PDF) and more.1.4 Table 8.61 · 1.7 Table 236PDF 1.2
ResetFormSet form fields back to their default values, the DV in each field.Fields the fields to reset, or to leave alone. Flags bit 1 picks which: include or exclude.1.4 Table 8.63 · 1.7 Table 238PDF 1.2
ImportDataFill in form fields from a Forms Data Format (FDF) file.F the FDF file.1.4 Table 8.65 · 1.7 Table 240PDF 1.2
JavaScriptRun a script. Scripts in the /JavaScript name tree of the document’s name dictionary run when the document opens, defining functions the others can call. PDF 2.0 calls these ECMAScript actions, but the /S value is still /JavaScript.JS the script, as a text string or stream: PDFDocEncoding, or UTF-16 with a byte order mark.1.4 Table 8.66 · 1.7 Table 217PDF 1.3

Multimedia and 3D

TypeWhat it doesEntriesAdded
SoundPlay a sound.Deprecated in PDF 2.0Sound the sound object. Volume −1.0 to 1.0. Synchronous, Repeat, Mix.1.4 Table 8.42 · 1.7 Table 208PDF 1.2
MoviePlay, stop, pause or resume the movie in a movie annotation.Deprecated in PDF 2.0Annotation or T picks the movie annotation (PDF 1.4 calls the first key Annot). Operation Play (the default), Stop, Pause or Resume.1.4 Table 8.43 · 1.7 Table 209PDF 1.2
RenditionPlay, stop, pause or resume a media clip (a rendition) in a screen annotation, or run a script that does something custom.OP the operation, 0 to 4. R the rendition. AN the screen annotation. JS a script, run instead of OP where the reader supports scripts.1.7 Table 214PDF 1.5
GoTo3DViewSet the view of a 3D annotation.TA the 3D annotation. V the view: a view dictionary, the index or the title of one of the views listed in the 3D stream, or /F, /L, /N, /P or /D for first, last, next, previous or default.1.7 Table 216PDF 1.6
RichMediaExecuteSend a command to the handler of a RichMedia annotation.TA the annotation. TI one instance of its content. CMD the command name and its arguments.2.0 Table 222PDF 2.0

The PDF 1.4 reference also mentions two older types: a set-state action, obsolete and not to be used, and a no-op action, defined in PDF 1.2 but never implemented and since dropped from the specification.

Chaining actions with Next

1.4 Table 8.291.7 Table 193

Every action dictionary can have these entries, whatever its type:

KeyValueAdded
Type/Action, if present.
SRequired. The type of action: one of the types above.
NextThe action to run after this one: one action dictionary, or an array of them to run in order.PDF 1.2

Since each action in /Next can have a /Next of its own, a chain can branch into a tree. The reader runs it depth first: an action, then everything chained after it, then the next action in the array. This button turns on a layer of answers, swaps itself for a “hide” button, and then redraws the page with a dissolve:

<< /S /SetOCGState /State [/ON 40 0 R]                    % 1. turn on the answers layer
   /Next [ << /S /Hide /T (showAnswers)                   % 2. hide this button
              /Next << /S /Hide /T (hideAnswers) /H false >> >>   % 3. show the other one
           << /S /Trans /Trans << /S /Dissolve >> >> ] >>      % 4. redraw, dissolving
  • Readers normally hold off redrawing until the whole chain has run. A Trans action shows the page as it is at that point, with a transition effect.
  • A reader shouldn’t run an action twice when a chain refers back to itself, and stops when an action, such as closing the document, makes the rest impossible.
  • An action shouldn’t change its own dictionary or any other in its chain; the result is undefined.

Where actions are triggered

1.4 §8.51.7 §12.6.1

An action runs only when something points to it. /A and /OpenAction hold one action each. An /AA entry holds an additional-actions dictionary, whose keys are trigger events and whose values are the actions to run.

WhereKeyWhen the action runsAdded
Document catalogOpenActionWhen the document opens. The value can be a destination array instead, as in the example.PDF 1.1
Document catalogAADocument triggers: before and after closing, saving and printing.PDF 1.4
Page objectAAPage triggers: when the page opens and closes.PDF 1.2
Outline itemAWhen the user clicks the bookmark. Not allowed alongside /Dest.PDF 1.1
Link, screen or widget annotationAWhen the user clicks the annotation. A link can’t have both /A and /Dest.PDF 1.1
Screen or widget annotationAAAnnotation triggers: the pointer, the mouse button, the focus, and the page it is on.PDF 1.2
Form fieldAAForm field triggers: keystrokes, formatting, validating and calculating its value.PDF 1.3

PDF 1.4 lists A and AA among the entries every annotation can have, noting that only widgets used AA. ISO 32000-1 puts A in the link, screen and widget annotation tables and AA in the screen and widget tables. The trigger keys below are the same in PDF 2.0.

Annotation triggers

1.4 Table 8.301.7 Table 194

Keys in the /AA of a screen or widget annotation:

KeyWhen the action runsAdded
EThe pointer enters the annotation’s active area.PDF 1.2
XThe pointer leaves it.PDF 1.2
DThe mouse button is pressed inside it.PDF 1.2
UThe mouse button is released inside it. If the annotation also has an /A, that runs instead.PDF 1.2
FoWidgets only: the annotation gets the input focus.PDF 1.2
BlWidgets only: it loses the focus (“blurred”).PDF 1.2
POThe page the annotation is on opens. Runs after the catalog’s /OpenAction and the page’s O.PDF 1.5
PCThat page closes. Runs before the page’s C.PDF 1.5
PVThat page becomes visible.PDF 1.5
PIThat page is no longer visible.PDF 1.5

PO, PC, PV and PI let an annotation carry its own page-open and page-close actions, so it can be moved or copied to another page with them. A page can be visible without being the open page, as in a two-page layout. An X needs an E before it, and a U needs an E and a D.

Page triggers

1.4 Table 8.311.7 Table 195

Keys in the /AA of a page object:

KeyWhen the action runsAdded
OThe page opens. When the catalog’s /OpenAction also runs, this runs after it.PDF 1.2
CThe page closes. Runs before any other page opens.PDF 1.2

Form field triggers

1.4 Table 8.321.7 Table 196

Keys in the /AA of a form field:

KeyWhen the action runsAdded
KKeystroke: the user types into a text field or combo box, or changes the selection in a list box. The script can check the change and reject or modify it.PDF 1.3
FFormat: before the field’s value is formatted for display. The script can change the value first.PDF 1.3
VValidate: the field’s value has changed. The script can check the new value.PDF 1.3
CCalculate: another field has changed, so recompute this one. The form dictionary’s /CO array sets the order.PDF 1.3

Each of these is a JavaScript action. None of them applies to button fields.

Document triggers

1.4 Table 8.331.7 Table 197

Keys in the /AA of the document catalog:

KeyWhen the action runsAdded
WCWill close: before the document closes.PDF 1.4
WSWill save: before the document is saved.PDF 1.4
DSDid save: after it is saved.PDF 1.4
WPWill print: before it is printed.PDF 1.4
DPDid print: after it is printed.PDF 1.4

Each of these is a JavaScript action. The PDF 1.4 reference names the first key DC (“document close”); ISO 32000-1 and PDF 2.0 name it WC.

Named actions

1.4 Table 8.451.7 Table 211

A Named action (PDF 1.2) runs a command built into the reader, given in /N: << /S /Named /N /NextPage >>. Every reader should support these four:

NameWhat it does
NextPageGo to the next page.
PrevPageGo to the previous page.
FirstPageGo to the first page.
LastPageGo to the last page.

Readers may support more names, but a file that uses them only works in those readers. A reader that doesn’t recognize the name, or finds it doesn’t make sense on its platform, does nothing. PDF 2.0 (Table 215) has the same four.

Example

A document that opens showing the whole first page, with one bookmark that jumps to another page and a link that opens a web address.

1 0 obj
<< /Type /Catalog /Pages 2 0 R /Outlines 20 0 R
   /OpenAction [3 0 R /Fit] >>            % open on the first page, whole page in view
endobj

20 0 obj                                  % the outline (bookmarks) root
<< /Type /Outlines /First 21 0 R /Last 21 0 R /Count 1 >>
endobj

21 0 obj                                  % one bookmark: the top of the page in object 7
<< /Title (Results) /Parent 20 0 R
   /A << /S /GoTo /D [7 0 R /XYZ 0 792 null] >> >>
endobj

12 0 obj                                  % a link, listed in a page's /Annots
<< /Type /Annot /Subtype /Link /Rect [72 600 250 614] /Border [0 0 0]
   /A << /S /URI /URI (https://example.com/data.csv) >> >>
endobj
  • /OpenAction holds a destination array here. An action dictionary works too.
  • The bookmark’s GoTo action does the same as /Dest [7 0 R /XYZ 0 792 null], which is shorter. /XYZ left top zoom puts the point (0, 792) at the top left of the window; null keeps the current zoom.
  • An outline item’s own /Next and /Prev (not needed here, with only one bookmark) point to its sibling bookmarks. They have nothing to do with an action’s /Next.
  • The link runs a URI action when clicked. Its other entries are on Annotation types.

1.4 Table 8.351.7 Table 199

Checked against §8.5 of the Adobe PDF Reference, third edition (PDF 1.4), Tables 8.29 to 8.34 and 8.45 and the action tables after them; §12.6 of ISO 32000-1:2008 (PDF 1.7), Tables 193 to 198 and 211 and the action tables after them, with the form actions in §12.7.5; and ISO 32000-2:2020 (PDF 2.0), Tables 197 to 201, for what PDF 2.0 adds and deprecates.

Section references such as 1.4 §3.4 1.7 §7.5 are to the Adobe PDF Reference, third edition (PDF 1.4) and ISO 32000-1:2008 (PDF 1.7). Where to get them: PDF specifications.