Quantcast
Channel: Adobe Community : Popular Discussions - JavaScript
Viewing all articles
Browse latest Browse all 12130

JavaScript: How do you pass the currently active doc to a dialog in a menu item?

$
0
0

I'm using Adobe Acrobat 11.0 Standard on Windows 7, and I'm having trouble with the menu item that I'm creating.  The menu item calls a dialog that prompts the user to select a page in the currently active document.  The problem is, I can't figure out how to pass the currently active document to the dialog.  I scoured the rest of the documentation, did searches on Google and here in the Adobe forums, but haven't turned anything up.  The AcroJS API gives the following solution (found under app/methods/execDialog):

 

This function attaches the Doc object to the dialog box, then passes the dialog box to the app.execDialog method. The dialog4 object and this function can be at the document level.

   function dotheDialog(dialog,doc)

    {

        dialog.doc = doc;

        var retn = app.execDialog( dialog )

    }

Finally, the following script can be executed from a mouse-up action, for example.

    dotheDialog( dialog4, this );

 

I did this exact thing, but in the dialog, the value of this.numPages still comes out as undefined, indicating that the current document still hasn't been passed.  My own code looks like this:

  function dotheDialog(dialog, thisDoc){

    dialog.doc = thisDoc;

    var retn = app.execDialog(dialog);

  }

 

 

  app.addMenuItem({

    cName: "Test Dialogue Box",

    cParent: "Edit",

    cExec: "dotheDialog(templateDialogue, this);"

  });

where templateDialogue is the name of my own dialog, rather than dialog4.  I'm not sure what the retn variable that they declare in the documentation is for, but I've tried it with and without that part, and it doesn't seem to make a difference.  Does anyone know how to do this?


Viewing all articles
Browse latest Browse all 12130

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>