2 Replies Latest reply on Mar 17, 2010 11:23 AM by cwadams1955

    Error "app.addMenuItem is not a function"




      New to Acrobat and Javascript in general.  I wanted to be able to create a custom toolbar with four buttons when a document is loaded (we don't want the buttons on the documents themselves), and I copied and pasted the following code into a module named "Open" to give me an example of how the commands work.  When I run it, I get the error in the thread title.  So I copied the first block of code - the "addMenuItem" command into the Javascript console and tried running it from there, and I get the same error.  Anyone have any idea what's going on here?  Thanks for any assistance you can give me.


      function(){return A.apply(null,[this].concat($A(arguments)))}

      //-----------------Do not edit the XML tags--------------------

      /*********** belongs to: Document-Level:Open ***********/
      var atbtoolbuttons;
      cName: "atbToolButtonSet",
      cUser: "My Menu",
      cParent: "Tools",
      cMarked: "event.rc = ( (typeof atbtoolbuttons != 'undefined') && !atbtoolbuttons )",
      cEnable: "event.rc = (event.target == null);",
      cExec: "loadATBToolButton();", nPos: 0

      var loadATBToolButton = app.trustedFunction( function ()
      if ( typeof atbtoolbuttons == "undefined" )
      atbtoolbuttons = true;
      else {
      if (!atbtoolbuttons) {
      atbtoolbuttons = true;
      if ( atbtoolbuttons ) {
      // Get the path to the user JavaScript folder
      var atbPath=app.getPath({cCategory: "user", cFolder: "javascript"});
      try {
      // Try opening the icon doc as in hidden mode, and retrieve its doc
      // object.
      var doc=app.openDoc({
      cPath: atbPath+"/icon_toolbar.pdf", bHidden: true});
      } catch (e) { console.println("Could not open icon file"); return;}
      // Get the icon stream for myIcon1 from the hidden doc
      var oIcon = util.iconStreamFromIcon(doc.getIcon("myIcon1"));
      // Add a tool button using this icon
      cName: "atbToolButton1",
      oIcon: oIcon,
      cExec: "atbTask1();",
      cTooltext: "My toolbar button 1",
      nPos: 0

      // Now get myIcon2 from the hidden document.
      oIcon = util.iconStreamFromIcon(doc.getIcon("myIcon2"));
      // and install this toolbar button as well
      cName: "atbToolButton2",
      oIcon: oIcon,
      cExec: "atbTask2()",
      cTooltext: "My toolbar button 2",
      nPos: 0
      // Close our hidden document containing the icons.
      // Set this variable to signal that the toolbars are installed.
      atbtoolbuttons = false;