PDF In-Depth

Forms - Something to Bear in Mind

February 14, 2001

Advertisement
Advertisement
 

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.

PDF In-Depth Free Product Trials Ubiquitous PDF

Debenu Quick PDF Library

Get products to market faster with this amazing PDF developer SDK. Over 900 functions and an equally...

Download free demo

Back to the past, 15 years ago! Open Publish 2002

Looking back to 2002, it's amazing how much of the prediction became a reality. Take a read and see what you think!

September 14, 2017
Platinum Sponsor





Search Planet PDF
more searching options...
Planet PDF Newsletter
Most Popular Articles
Featured Product

Debenu PDF Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link control. Take Acrobat to the next level.

Features

Adding a PDF Stamp Comment

OK, so you want to stamp your document. Maybe you need to give reviewers some advice about the document's status or sensitivity. This tip from author Ted Padova demonstrates how to add stamps with the Stamp Tool along with related comments.