4 Replies Latest reply on Nov 1, 2012 12:41 PM by Saulius Stonys

    Image in dialog(execdialog)

      Hy,

      I would like to insert an image in a dialog. And the resulting PDF should be visible in Acrobat Reader too.
      Here is my script without the image:

      =========================================
      var oDlg =
      {
      description:
      {
      name: "dialog1",
      elements:
      [
      {
      name: "Hello Word!",
      type: "static_text",
      },
      {
      type: "ok",
      },
      ]
      }
      };
      // Dialog Activation

      function myFunction( )
      {
      if(!done )
      {
      done=1;
      app.execDialog(oDlg);
      }
      }
      =============================================

      Could You please show me what the script should look like to have an image in It?
      NB: I want replies about scripting not about how to that from acrobat IDE

      Thanx
        • 1. Re: Image in dialog(execdialog)
          gkaiseril MVP & Adobe Community Professional
          Have your gotten your code to work?

          Try:

          // define dilog object
          var oDlg = {

          initialize: function (dialog1) {
          // create a static text containing the current date.
            var todayDate = dialog.store()["date"];
          todayDate = "Date: " + util.printd("mmmm dd, yyyy", new Date());
          dialog.load({ "date": todayDate });
          },

          commit:function (oDlg) {
          // called when OK pressed
          app.alert("Done",3,0);
          },

          cancel:function (oDlg) {
          // called when Canceled pressed
          app.alert("Canceled",3,0);
          },

          description:
          {
          name: "My Dialog", // dialog title

          elements:
          [
          {
          type: "cluster", elements:
          [
          { // static text
          name: "Hello Word!",
          type: "static_text",
          }, // end static text

          { // define ok cancel buttons
          type: "ok_cancel",
          ok_name: "Ok",
          cancel_name: "Cancel"
          } // end ok_canel buttons

          ] // cluster
          }
          ] // end elements
          } // end description
          }; // end of dialog object

          app.execDialog(oDlg);
          • 2. Re: Image in dialog(execdialog)
            Thom Parker Adobe Community Professional
            Images for both dialogs and toolbar buttons are represented with a Generic Icon Stream. The stream object is very simple

            var oIconStm = {width:100, height:100, read: function(nBytes){..}};

            It includes the width, height, and a function for returning bytes from the image data. All this is outlined in the Acrobat JavaScript Reference, including the image format, which is 4 byte SRGB, where the S is the alpa channel.

            The easiest, best, and most robust way to deal with creating images and dialogs is to purchase AcroDialogs:

            http://www.windjack.com/products/acrodialogs.html

            , which is an Acrobat Plugin for doing this.

            But there is another way to put images in a dialog where don't have to worry too much about the image details. The "util" object contains a function for converting an Icon Object into a Generic Icon Stream that can then be used on either a toolbar button or in a dialog image element. This strategy only works well on within a document, but it can also be used, with a little creative scripting, in a folder level script.

            Here's a simple script:

            var oButIcon = this.getField("MyIconButton").buttonGetIcon();
            var oMyIcon = util.iconStreamFromIcon(oButIcon);

            var oDlg1 =
            {
            initialize: function(dialog)
            {
            dialog.load({"img1":oMyIcon});
            },
            description:
            {
            name: "JSADM Dialog",
            elements:
            [
            {
            type: "image",
            item_id: "img1",
            width: 100,
            height: 100,
            }
            ]
            }
            };

            The image is stored on the current document in a button named "MyIconButton".
            • 3. Re: Image in dialog(execdialog)
              garek007 Level 1

              Tom,

               

              You mentioned that your script below is a folder level script. How does it get accessed from Acrobat? I see no UI button code adding a button to your menu in that script.

              • 4. Re: Image in dialog(execdialog)
                Saulius Stonys

                maybe there you could find an answer:

                 

                http://xprepress.com/images-in-acrobat-dialog-1/

                http://xprepress.com/images-in-acrobat-dialog-2/

                 

                -----

                Saulius Stonys

                www.xprepress.com