Forms – Something to Bear in Mind

Something to bear in mind about our discussions of JavaScript in PDF documents:

JavaScript for PDF doesn’t always have to be for Forms. Always remember that there are 4

places where you can attach JavaScripts:

  • Page-open actions. (In Acrobat, Document menu, Set Page Action…

    command.)

  • Top-level scripts. (Tools:Forms:Document JavaScripts.)
  • Links. (Use Link tool, then set Action type in Create Link dialog box.)
  • Form fields. (Use Form tool, set up Action.)

Contextual usage

Now, in the first three instances here, you’re not necessarily dealing with forms at all.

You can create JavaScripts in 1, 2, and 3 above without making a PDF doc into a form. Why

would you use JavaScript in a regular PDF document where there are not fields to manipulate?

Go back and look at the Acrobat Forms JavaScript Object Specification documentation. The

‘fields object’ methods only account for about half the available properties and methods in

the Acrobat JavaScript model. You’ve also got App and Doc methods, with which you can do

things like:

  • Programmatically control fullscreen vs. not-fullscreen viewing mode.
  • Programmatically control the zoom factor.
  • Programmatically control the current page number.
  • Programmatically control the current view type.
  • Programmatically control the presence/absence of toolbars.
  • Make menu commands execute programmatically.
  • Issue alert dialogs. And system beeps.
  • Issue response dialogs. These are useful for gathering user input without form fields.
  • Jump to URLs.
  • Send e-mails.
  • Go backward and forward on the view stack.
  • and more.

Now you might be saying, ‘But in response to what kind of events?’ The answer is, your

scripts can be entered at the time any page is opened or closed, or in response to mouse

clicks. ‘What mouse clicks?’ you may be wondering. Clicks on links, of course! One of the

options you have when setting up Links in Acrobat is to have a click on a link activate a

JavaScript. Since links can be visible (or invisible in the case where you already have a

visible object on the page that you want people to click on), you can consider them custom

buttons, of a sort.

I only bring all this up to remind everyone (myself included) that when we talk about

JavaScript, we don’t necessarily have to limit our discussion to Acrobat Forms, since any

PDF doc can use JavaScript. The uses are up to you.

You May Also Like

About the Author: Kas Thomas

Leave a Reply