Acrobat JavaScript Extensions – Hello World

When we think "adding a button to the Acrobat Toolbar or Menu Item" we think: C++ Plugin; There is a far easier and less known alternative via JavaScript. That’s what I’d like to write about today. I’ve finished a project using JavaScript extensions for Acrobat, the customer is very happy because he can and did modify the extension himself. The one caveat is that not all the C++ functions are available in JavaScript but nonetheless still powerful.

I like the traditional "Hello World" examples, that’s what I look for when ever I start coding in a new language, framework or library; so I’ll give the reader a "Hello World" example.

Check the JavaScript for Acrobat Documentation for the exact use of each library call.

So open up your favorite text editor and the following self-explanatory code to HelloWorld.js

function helloWorld()
     //Say Hello World
     app.alert("Hello World");

       cName: "helloWorldBtn", // A name for your button
       cExec: "helloWorld()", //Function to Call
       cLabel: "Hello World", //The Text on the Button
       cTooltext: "Say Hello World" //The Help Text

Drop the HelloWorld.js to:

  • Mac – /Users/<user id>/Library/Application Support/Adobe/Acrobat/9.0_x86/ JavaScripts
  • Vista – C:\Users\<user id>\AppData\Roaming\Adobe\Acrobat\9.0\JavaScripts

Restart Acrobat and open-up any PDF and you should see the following button added to the tool-bar.


Clicking on the button you should see your Hello World alert.


2 Responses to Acrobat JavaScript Extensions – Hello World

  1. Pingback: Silent Print in Acrobat Using JavaScript « Adobe Consulting Public Sector

  2. Paxton says:

    Very cool