These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Document Javascript

riccarrasquilla
Registered: Sep 24 2008
Posts: 27
Answered

I'm trying to get this simple script to work under Advanced->Document Processing -> Document Javascripts

Init

function Init()
{
app.alert('me');
}

After I save and open the file, I don't get my alert box. any ideas.

My Product Information:
Acrobat Pro Extended 8.1.2, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
You would have to invoke that function to get it to do anything.

If you want code to execute when a document is first opened, you can place it in a document-level JavaScript but outside of a function definition, or invoke the function, which you can do a number of ways. In your example, you could do:

// Define the functionfunction init() {app.alert("me");} // Invoke the functioninit();

If you only need to run it once at startup, you can simply do:

// Define anonymous function and have it call itself(function {app.alert("me");})();

Or in this case, this is equivalent:

app.alert("me");
George