You can write a document-level function into the actions handlers using the doc.setAction() method from a folder-level script, but one folder-level script cannot create another.
Suppose you have a folder-level function triggered by a menu item, and it has collected a reference to the active document as oDoc:
var myScript = 'console.println("I am about to be printed and I have " + this.numPages + " pages" );';
I tried to embed the script "this.setAction("WillPrint",app.alert("hi");)", but this script does not get executed when i open the print console from the acrobat reader. not sure what's wrong. Quick advise will be greatly helpful.
WillPrint is fired when the document WILL print - after you press the Print button on the dialog.
to execute the app.alert at the time setAction is called, and to set an empty action. The action needs to be something that is NOT executed immediately (e.g. string).