Editor’s Note: This article is part of the Introduction to Acrobat Development Learning Center
width=’152′ height=’150′ alt=’AcroJS’ align=’right’>
Repetitive tasks are the most common reason for using AcroJS. AcroJS allows you to automate tasks that you do manually time and time again, for example you could write some AcroJS that is part of a Batch Sequence to add a series of Bookmarks to a folder of PDF documents.
If you have created some PDF Forms and want to ensure your users enter only valid data then you could use AcroJS to validate and control the data entered. For example you could make use of Regular Expressions to validate a Social Security Number or an Email Address (link to new article).
If you have a full version of Acrobat (v5, v6 Std, v6 Pro) we can make use of Templates to create a dynamic PDF. Templates (link) provide a way to dynamically add marked elements to a pre-existing PDF, elements such as graphics, form fields and text.
The Acrobat Document Object Model (ADOM)
Each diagram illustrates the hierarchy of objects in each respective environment.
src=’http://www.planetpdf.com/planetpdf/images/2-ITAD_LC_DWJ.gif’ width=’400′ height=’242′
src=’http://www.planetpdf.com/planetpdf/images/3-ITAD_LC_DWJ.gif’ width=’400′ height=’227′
width=’219′ height=’216′ alt=’AcroJS levels’ align=’right’>
- Folder/Application level
- Document level
- Page level
- Form field level
- Bookmark/Link level
Document level scripts reside inside the PDF and are available and accessible to all other elements and scripts in the PDF. (links)
Page level scripts aren’t accessible by/from any other elements and can be one or both of the following types: Page Open Action or Page Close Action. (links)
AcroJS placed at the form field level can be placed in various locations:
- Calculation Script
- Validation Script
- Format Script
- Event triggered Script
- Keystroke Script
As you can see AcroJS at the Form Field level provides a great number of choices.
When you need to run a script that’s activated when you click a Bookmark or a Link then Acrobat provides this functionality as well.
Limitations and Possibilities