4 Replies Latest reply on Aug 19, 2014 6:19 PM by Alexito

    initialize dialog with img

    Alexito

      Hello,

       

      I want to import img to a dialog, as it is shown here: Images in Acrobat JavaScript Dialog Part 2 at Extra prepress

       

      I import my icon on the other way and it is loaded, as the button appears with this icon. The iconToHex.pdf has two images assigned to the fields: Button1 and img2.  The icon Button1 is imported to the button "Smile" and the other icon "img2 " I am trying to import into the dialog, but it doesn't work . The dialog appears with two buttons : "Close" and "Wink" and under the buttons is an Warning: JavaScript Window .I tried different icon sizes for  "img2 " : 20x20 and 200x200 as well, it doesn't work. Could you help me please to get the icon in the dialog.

       

      var importImg = app.trustedFunction(function(targetImg) {

            try {

             var shortPath = "/Macintosh HD/Users/tmpAcrobat/";

             app.beginPriv();

             var doc = app.openDoc({

                  cPath: shortPath + "iconToHex.pdf",

                  bHidden: true

              });

              app.endPriv();

            } catch (e) {

              console.println("Could not open icon file: " + e);

              return;

          }

          var myIcon = doc.getField(targetImg).buttonGetIcon();

          var streamIcon = util.iconStreamFromIcon(myIcon);

          return streamIcon;

      });

       

      // IMPORT IMAGES:

      var oIcon = importImg("Button1");

      var oSmile = importImg("img2");

      var oWink = importImg("img2");

       

       

      app.addToolButton({

          cName: "btnDialog",

          cEnable: true,

          oIcon: oIcon,

          cExec: "app.execDialog(myDialog)",

          cLabel: "Smile",

          cTooltext: "cTooltextSmile1",

          nPos: -1

      });

       

      var myDialog = {

       

          // Load the initial image

          initialize: function(dialog) {

              this.t = 1; // status value of the image

              dialog.load({

                  img1: oSmile,

              });

          },

       

          // called when the 'wink' button pressed

          tumb: function(dialog) {

       

              if (this.t == 0) {

                  dialog.load({

                      img1: oSmile,

                      tumb: "Wink"

                  });

              } else {

                  dialog.load({

                      img1: oWink,

                      tumb: "Smile"

                  });

              }

       

              // swap status value of the image

              this.t = (this.t - 1) * -1;

       

          },

       

          // called when cancel button pressed

          clos: function(dialog) {

              dialog.end("cancel")

          },

       

          // describes an appearance of the dialog box

          description: {

       

              name: "Smile", // Dialog box title

              elements: [{

                  type: "image", // type of element

                  height: 200, // height of the element in pixels

                  width: 200, // width of the element in pixels

                  item_id: "img1" // an ItemID of this element

       

              }, {

                  type: "view",

                  align_children: "align_row",

                  elements: [{

                      // close button

                      type: "button",

                      item_id: "clos",

                      name: "Close"

                  }, {

                      // image switcher button

                      item_id: "tumb",

                      type: "button",

                      name: "Wink"

                  }]

              }]

          }

       

      };

       

      regards,

      Alex

        • 1. Re: initialize dialog with img
          gkaiseril MVP & Adobe Community Professional

          What version of Acrobat/Reader?

           

          Have you tried the run the supplied JS file?

           

          The author has the text for the icon images in the file and converts the text to an icon image. No importing.

          • 2. Re: initialize dialog with img
            Alexito Level 1

            Version 11.0.07

            I tried with text as well. It doesn't work. actually it is the same, I just save some steps with encoding and decoding in order to get the same picture. It is no probem with importing into document, it is problem to put this image into the dialog.
            Or can I put the image to the dialog somehow else?

            • 3. Re: initialize dialog with img
              try67 MVP & Adobe Community Professional

              There's a bug in that version of Acrobat (and maybe Reader as well). It will not show images in a dialog object.

              • 4. Re: initialize dialog with img
                Alexito Level 1

                It is bad

                 

                Ok, I've got a new idea. For this I need to get opened an other pdf with images using JS. Can I set the size of the windows for a new document, i.e. are there parameters in the following function, like width , height and that new Acrobat window should be not active(is not placed over the origin(main) document)? I could not find it in documents like JSGuide and API.

                 

                app.openDoc({

                            cPath: shortPath + "iconToHex.pdf",

                           //windowWidth ?

                          //windowHeight

                });