17 Replies Latest reply on Apr 1, 2015 6:56 AM by JamesHaney

    Display document data in dialog box

    JamesHaney Level 1

      I am using a folder level script to do the following:

       

      Get a specific XMP field value from an open PDF file:

      this.info.InDesignFileName

       

      Define a dialog box

       

      Create a menu item that calls the dialog box

       

      But for the life of me, I cannot get the dialog creation function to populate the XMP value into a static text item.

       

      The function below is modified from the example right out of the Acrobat Javascript API Reference.

       

       

      var inDesignNameDialog = {

      initialize: function (dialog) {

      // store InDesignFileName XMP

      //var indfn = this.info.InDesignFileName

      // 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 });

      */

      var todayDate = dialog.store()["indfn"];

      currFN = "Date: " + this.info.InDesignFileName;

      dialog.load({ "indfn": currFN });

       

      },

      commit:function (dialog) { // called when OK pressed

      var results = dialog.store();

      // Now do something with the data collected, for example,

      console.println("Your name is " + results["fnam"]

      + " " + results["lnam"] );

      },

      description:

      {

      name: "Personal Data", // Dialog box title

      align_children: "align_left",

      width: 350,

      height: 200,

      elements:

      [

      {

      type: "cluster",

      name: "Your Name",

      align_children: "align_left",

      elements:

      [

      {

      type: "view",

      align_children: "align_row",

      elements:

      [

      {

      type: "static_text",

      name: "First Name: "

      },

      {

      item_id: "fnam",

      type: "edit_text",

      alignment: "align_fill",

      width: 300,

      height: 20

      }

      ]

      },

      {

      type: "view",

      align_children: "align_row",

      elements:

      [

      {

      type: "static_text",

      name: "Last Name: "

      },

      {

      item_id: "lnam",

      type: "edit_text",

      alignment: "align_fill",

      width: 300,

      height: 20

      }

      ]

      },

      {

      type: "static_text",

      name: "InDesign File Name: ",

      char_width: 50,

      item_id: "indfn"

      },

      ]

      },

      {

      alignment: "align_right",

      type: "ok_cancel",

      ok_name: "Ok",

      cancel_name: "Cancel"

      }

      ]

      }

      };