If you intend to create forms for your website, whether authored in HTML or in PDF,
language, you’ll need to read up.
$17.95 list, it’s a bargain. When you graduate from that book to needing a for-real
heavy-duty text covering the language in some depth, you have no option (in my opinion) but
a rhino on the cover).
access to a great deal of browser functionality via methods that access the Document Object
inside the PDF spec, that does not mean you can access browser functions or HTML document
gets executed inside Acrobat or Acrobat Reader. The browser knows nothing about this.
Indeed, you can’t reach the browser from within a PDF file. They live in separate
objects, with methods available only to PDF files. These objects and methods are covered in
Adobe’s documentation. Look for a document called AcroJS.pdf on Adobe’s web site or
implemented. Early in the document it states:
defined within the Adobe Acrobat realm and are specific to Acrobat Forms. They basically
mirror the Acrobat Forms components and give the forms developer a way to access these
components programmatically in order to query and change their properties. In addition to
defining forms specific objects, there are additional generic objects that allows the
developer to access the underlying document and perform certain actions on it.
An example of an additional object is the app object, which has methods like
beep and alert. (These methods issue a system beep and an alert dialog,
respectively.) The app object also has properties. One property it has is the
fullscreen attribute, which is a Boolean value. If you call
app.fullscreen = true
(i.e., Acrobat Reader) into fullscreen mode, making menus disappear and generally making it
seem as if your form has taken over the user’s machine. (This may be disconcerting to the
user, of course!) If you set this value to False, you will make the viewing app go back to
its default viewing mode.
In HTML, you insert JS code into your main HTML document, usually in various places
throughout the document, and the document ends up being quite long and almost impossible for
a normal human being to read and understand.
In PDF, you attach JS snippets to individual widgets visually, with the mouse,using
Acrobat’s form tool. Choose the form tool, then doubleclick on whichever field you want to
attach JS to. Click the Actions tab and decide whether to attach your code to a mouse
action, or make it a Validate script, or a Calculate script, or a Format script. (These
latter options will mainly be available in Text fields.) For example, select a mouse action,
Take a look at the following code, which shows how to change the Fill Color of all of a
PDF form’s fields at runtime:
var rgb = new Array('RGB',.5,.5,.5);
for(var i =0;i<this.numfields; i++)
We will walk through this code step by step, in great detail, later.