Applying actions and scripts to PDFs

About actions

You can cause an action to occur when a bookmark or link is clicked, or when a page is viewed. For example, you can use links and bookmarks to jump to different locations in a document, execute commands from a menu, and perform other actions. Actions are set in the Properties dialog box.

For bookmarks or links, you specify an action that occurs when the bookmark or link is clicked. For other items, such as pages, media clips and form fields, you define a trigger that causes the action to occur and then define the action itself. You can add multiple actions to one trigger.

The Locked option prevents the appearance and actions associated with an object from being accidentally changed.

Add an action to bookmarks, form fields, buttons, or clips

  1. Do one of the following:
    • Using the Hand tool, right-click the bookmark, and choose Properties.

    • Using the Tools > Rich Media > Select Object tool, double-click the link, media clip, or form field, and choose Properties.

  2. Click the Actions tab.

  3. From the Select Action menu, select the action type to occur, and then click Add. You can add multiple actions; actions execute in the order that they appear in the Actions list box.

  4. (Optional) Select an action in the Actions tab, and use the buttons to reorder, edit, or delete the action.

  5. Click OK to accept the actions. To close the Rich Media tool, click the cross icon at the right-end of the toolbar.

Add actions to page thumbnails

To enhance the interactive quality of a document, you can specify actions, such as changing the zoom value, to occur when a page is opened or closed.

  1. Click the Page Thumbnails button on the left.

  2. Select the page thumbnail corresponding to the page, and choose Page Properties from the options menu .

  3. Click the Actions tab.

  4. From the Select Trigger menu, choose Page Open to set an action when the page opens, or choose Page Close to set an action when the page closes.

  5. Choose an action from the Select Action menu, and click Add.

  6. Specify the options for the action, and click OK. The options available depend on the action selected.

  7. To create a series of actions, choose another action from the menu, and click Add again. Use the Up and Down buttons to arrange the actions in the order you want them to occur.

    Note:

    If you set an action that switches to Full Screen view on Page Open or Page Close, the next time the same page opens or closes, Full Screen view is turned on.

  8. Close all opened dialog boxes, if any. Click the cross icon at the right-end of the toolbar to close the tool.

Action types

You can assign the following actions to links, bookmarks, pages, media clips, and form fields:

Execute A Menu Item

Executes a specified menu command as the action.

Go To A 3D/Multimedia View

Jumps to the specified 3D view.

Go To A Page View

Jumps to the specified destination in the current document or in another document.

Import Form Data

Brings in form data from another file, and places it in the active form.

Multimedia Operation (Acrobat 9 And Later)

Executes a specified action for a multimedia object in the file (such as playing a sound file). The multimedia object must be added to the file before you can specify an action for it.

Open A File

Launches and opens a file. If you are distributing a PDF file with a link to another file, the reader needs the native application of that linked file to open it successfully. (You may need to add opening preferences for the target file.)

Open A Web Link

Jumps to the specified destination on the Internet. You can use http, ftp, and mailto protocols to define your link.

Play A Sound

Plays the specified sound file. The sound is embedded into the PDF document in a cross-platform format.

Play Media (Acrobat 5 Compatible)

Plays the specified QuickTime or AVI movie that was created as Acrobat 5-compatible. The specified movie must be embedded in a PDF document.

Play Media (Acrobat 6 And Later Compatible)

Plays a specified movie that was created as Acrobat 6-compatible. The specified movie must be embedded in a PDF document.

Read An Article

Follows an article thread in the active document or in another PDF document.

Reset A Form

Clears previously entered data in a form. You can control the fields that are reset with the Select Fields dialog box.

Run A JavaScript

Runs the specified JavaScript.

Set Layer Visibility

Determines which layer settings are active. Before you add this action, specify the appropriate layer settings.

Show/Hide A Field

Toggles between showing and hiding a field in a PDF document. This option is especially useful in form fields. For example, if you want an object to pop up whenever the pointer is over a button, you can set an action that shows a field on the Mouse Enter trigger and hides a field on Mouse Exit.

Submit A Form

Sends the form data to the specified URL.

Trigger types

Triggers determine how actions are activated in media clips, pages, and form fields. For example, you can specify a movie or sound clip to play when a page is opened or closed. The available options depend on the specified page element.

You can use the following triggers for media clips and form fields (not links or bookmarks):

Mouse Up (Acrobat Pro)

When the mouse button is released after a click. This is the most common button trigger, because it gives the user one last chance to drag the pointer off the button and not activate the action.

Page Visible (media clips only)

When the page containing the media clip is visible, regardless of whether it is the current page. It’s possible for a page to be visible without being the current page, such as when a continuous page layout displays pages side-by-side.

Page Invisible (media clips only)

When the page containing the media clip is moved out of view.

Page Enter (media clips only)

When the page containing the media clip becomes the current page.

Page Exit (media clips only)

When a user leaves the page that contains the media clip.

Mouse Down

When the mouse button is clicked (without being released). In most cases, Mouse Up is the preferred trigger.

Mouse Enter

When the pointer enters the field or play area.

Mouse Exit

When the pointer exits the field or play area.

On Receive Focus (media clips only)

When the link area receives focus, either through a mouse action or tabbing.

On Lose Focus (media clips only)

When the focus moves to a different link area.

About JavaScript in Acrobat

The JavaScript language was developed by Netscape Communications as a means to create interactive web pages more easily. Adobe has enhanced JavaScript so that you can easily integrate this level of interactivity into your PDF documents.

You can invoke JavaScript code using actions associated with bookmarks, links, and pages. The Set Document Actions command lets you create document-level JavaScript actions that apply to the entire document. For example, selecting Document Did Save runs the JavaScript after a document is saved.

Acrobat Pro is required to use JavaScript with forms and action wizards.

In Acrobat Pro, you can also use JavaScript with PDF forms and action wizard. The most common uses for JavaScript in forms are formatting data, calculating data, validating data, and assigning an action. Field-level scripts are associated with a specific form field or fields, such as a button. This type of script is executed when an event occurs, such as a Mouse Up action.

To learn how to create JavaScript scripts, download the JavaScript manuals from the Adobe website. Developing Acrobat®Applications Using JavaScript™ contains background information and tutorials, and the JavaScript™ for Acrobat®API Reference contains detailed reference information. These and other JavaScript resources are located on the Adobe website.

Get help faster and easier

New user?