How do JavaScript actions work?

Soda PDF 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.

Below is a short example demonstrating how to set this up using JavaScript inside a PDF Link Action.

  • Open the Insert Tab.
  • 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. 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 view mode first!), you will see the alert box popping up.

Was this article helpful?

Yes No
Have more questions? Submit a request