Skip navigation
DurgaCharan
Currently Being Moderated

Add application and document level events using javascript

Aug 6, 2012 7:12 AM

Hi All,

 

I need to do some validation in the preprint event of the pdf document. There are samples available using the UI and adding the script in the script dialog, but my requirement is that i need to map the 'preprint' event and event handler to the pdf document using pure javascript code without the UI. Any help would be greatly helpful. Thanks in advance.

 

Regards,

Charan

 
Replies
  • Currently Being Moderated
    Aug 6, 2012 8:34 AM   in reply to DurgaCharan

    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" );';

    oDoc.setAction("WillPrint",myScript);

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 7, 2012 12:51 AM   in reply to DurgaCharan

    WillPrint is fired when the document WILL print - after you press the Print button on the dialog.

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 7, 2012 5:43 AM   in reply to DurgaCharan

    I'd expect

    this.setAction("WillPrint",app.alert("hi");

    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).

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points