4 Replies Latest reply on Mar 17, 2014 4:05 PM by George_Johnson

    Auto run Action on Document Open

    Teivioko

      This is my first time posting here and first time using any sort of javascript / Adobe SDK so please don't be too rough on me.

       

      But what I have is an Action setup that runs Javascript to insert a mouse up action into a Digital Signature field (that is placed post-print from another program) and place a standard text box. The code is working just fine doing what it needs to, well my end users don't like having to push a button (go figure) and I am trying to automate the process when a document is opened with a certain title.

       

      The code isn't throwing any errors and isn't working and I am stuck. I have been using the Adobe SDK pdf in my adventure into javascript and its been doing just fine for me until now.

       

      The code will eventually insert javascript into 4 different Digital Signature fields and place 4 text boxes all with action's tied to them. I am currently just trying to get one to work. here is what i have so far, any help would be greatly appreciated.

       

      The Blue section is what I have working in the Action Script, Red is where I am having issues.

       

      var d = app.activeDocs;

      for (var i=0; i < d.length; i++)

      if (d[i].info.Title == "DIGSIGTEST")

      {

      var aCropRect = this.getPageBox("Crop",0);

      var nRight = aCropRect[2]/1;

      var a = "if (!this.getField(\"CHIEF_ENGINEER\").value) this.getField(\"DATE_1\").value = \"\";\relse this.getField(\"DATE_1\").value = util.printd(\"mm/dd/yyyy\", new Date());";

      d[i].getField("CHIEF_ENGINEER").setAction("MouseUp",a);

      // Field is along bottom edge of crop, 400 points wide, 20 points tall

      var rectFld = [];

      rectFld[0] = nRight-98; // Left side is 150pts to the left of the right

      rectFld[1] = aCropRect[3]+275;  // Top side is 400pts above the bottom

      rectFld[2] = nRight-20; // Right side is -25pts to the right of the right

      rectFld[3] = aCropRect[3]+230;  // Bottom is 360pts above the bottom of Crop Box

      //Add Field

      var oFld = this.addField("DATE_1", "text", 0, rectFld);

      var ccalc = "if (!this.getField(\"CHIEF_ENGINEER\").value) this.getField(\"DATE_1\").value = \"\";";

      this.getField("DATE_1").setAction("Calculate",ccalc);

      }

       

      Im using Adobe X Pro and notepadd++