PDF Architect

The ONLY Customizable PDF Editor

How do JavaScript link actions work?

PDF Architect allows you to use all capabilities specified in the JavaScript™ for Acrobat® API Reference
This gives you an extensive object model. This may be different from JavaScript as it is used in browsers.
This is a short sample to demontrate how to query the user with an alert box using JavaScript inside a PDF Link Action.

  • Open the Review module
  • Select the Link tool
  • Select an area you would like to cover with the link
  • A Window with the available actions pops up. Add A JavaScript Action here
  • Insert the following code:

    var answer = app.alert("Do you say yes or no?", 2, 2);
    
    /* Question icon, Yes/No button. */
    /* 0 = error, 1 = OK, 2 = Cancel, 3 = No, 4 = Yes */
    
    if (answer == 4)
    {
       app.alert("You said yes!");
    }
    else
    {
       app.alert("You said no!");
    }
    

When you click on the link you have created (change to select mode first!), you will see the alert box popping up.