What is Acrobat JavaScript?

Editor’s Note: This article is part of the Introduction to Acrobat JavaScript Learning Center

A long time ago in a galaxy far, far, away, oh, hang on that story’s already been told, so let’s have a look at Acrobat JavaScript instead. AcroJS as it’s known in the world of Acrobat development is the scripting language of choice (actually there’s only one scripting language so choice isn’t an option).

To be a little more precise Acrobat JavaScript is a programming language that is contained inside Acrobat Standard and Acrobat Professional. Its sole purpose in life is to allow the developer to write scripts (programming code) that automates tasks that would otherwise be time consuming and mind numbing.

So what’s a scripting language?

Basically a scripting language is a programming language that generally resides inside a host application and provides a sticky-gooey layer that makes it easy to automate otherwise boring and monotonous jobs and because it generally resides inside of a host application it has access to functions that mere mortal users don’t.

Other examples of scripting languages include Visual Basic for Applications (VBA), Windows Scripting, VBScript and some might even argue that Perl is a scripting language (not me though, I just like to stir the pot).

In the case of AcroJS there’s a great deal of power to be had with scripting the features and functions inside Acrobat. You can make mince meat of those tasks that you normally farm out to the junior in the office.

If you’ve ever heard of JavaScript it’s more than likely that you’ve heard about it in relation to Web Browser’s, it’s here that JavaScript (which is based on ECMA Script) really took off as the scripting language to make those dancing elephants fly across the screen or the blinking text that simply wont stop blinking. In fact JavaScript in the browser shares a lot of similarities to JavaScript in Acrobat — except for one small difference, its Document Object Model (DOM).

What’s all this DOM business then?

The DOM is probably the most controversial thing since Microsoft introduced that annoying clippy assistant. A Document Object Model represents how the host application looks (and feels) to the scripting programmer. The differences in the DOM are what make Acrobat and Web browsers different from the perspective of the JavaScript programmer.

Using the DOM, you gain access to the PDF document (and Acrobat) in a structured and object oriented fashion. A document object model basically sets out what objects exists in the document and also which features they provide to the programmer.

So where do I put this JavaScript stuff?

It turns out that you can stuff JavaScript into most places in Acrobat, including (but not limited to), form field buttons, page open and close actions and document opening and closing actions. But wait there’s more. (an offer for free steak knives is included at the bottom of this article). It turns out that you can also write JavaScript and place it at the Document Level, Application Level and Page Level, the biggest reason you might do this is so you can have central locations from which to call or execute JavaScript from.

Where to from here?

The good news is that you don’t have to be a hardcore C++ programmer to write JavaScript — it’s really easy, and the wonderful thing about writing JavaScript is that you only need to learn a little bit to accomplish a lot.

So to make your introduction to the world of AcroJS a little smoother, we’ve prepared a whole series of articles on AcroJS, including another introductory article explaining where you can use JavaScript in Acrobat. So let’s get started on the road to AcroJS wisdom.

You May Also Like

About the Author: Dave Wraight

Leave a Reply