12 Replies Latest reply on Mar 3, 2014 11:49 AM by EPKI Guy

    Programmatically adding JS to Digital Signature fields

    EPKI Guy Level 1

      Good Morning, I have a JavaScript that populates my adobe document with 3 signature fields and 3 date fields all in the right place....then, the same code puts JS in the calculate tab of the date fields as needed.  What I can't seem to figure out is how to populate the signature fields with the JS I need for them to have as well.

       

      The code for the custom action I created is below:

       

      // First, acquire the Crop Box for Page #1

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

       

      // Calculate the placement rectangle for the text box.

      // Field is in the title block for signature

      var nRight = aCropRect[2]/1; 

       

      // Field is above the bottom 162pts, 250 points wide, 50 points tall

      var rectFld = [];

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

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

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

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

       

      // Add Field

      var oFld = this.addField("Signature1", "signature", 0, rectFld);

       

       

      // Field is above the bottom 162pts, 78 points wide, 50 points tall

      var rectFld = [];

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

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

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

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

       

       

      // Add Field

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

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

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

       

       

      // Field is above the bottom 225pts, 250 points wide, 50 points tall

      var rectFld = [];

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

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

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

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

       

      // Add Field

      var oFld = this.addField("Signature2", "signature", 0, rectFld);

       

       

      // Field is above the bottom 225pts, 78 points wide, 50 points tall

      var rectFld = [];

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

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

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

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

       

       

       

      // Add Field

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

      var ccalc = "if (!this.getField(\"Signature2\").value) this.getField(\"DATE_2\").value = \"\";";

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

       

       

      // Field is above the bottom 495pts, 75 points wide, 25 points tall

      var rectFld = [];

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

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

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

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

       

      // Add Field

      var oFld = this.addField("Signature3", "signature", 0, rectFld);

       

       

      // Field is above the bottom 495pts, 60 points wide, 25 points tall

      var rectFld = [];

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

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

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

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

       

       

       

      // Add Field

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

      var ccalc = "if (!this.getField(\"Signature3\").value) this.getField(\"DATE_3\").value = \"\" (util.printd (\"mm/dd/yyyy\", new Date()));";

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

       

       

       

       

      Here is the stuff I need in the signature fields respectively....

       

       

      if (!this.getField(\'Signature1\').value) (this.getField(\'DATE_1\').value) = \"\" (this.getField(\'DATE_1\').value = util.printd("mm/dd/yyyy", new Date()));

      if (!this.getField(\'Signature2\').value) (this.getField(\'DATE_2\').value) = \"\" (this.getField(\'DATE_2\').value = util.printd("mm/dd/yyyy", new Date()));

      if (!this.getField(\'Signature3\').value) (this.getField(\'DATE_3\').value) = \"\" (this.getField(\'DATE_3\').value = util.printd("mm/dd/yyyy", new Date()));

       

      I am assuming it starts like this but have no clue...

       

      var s = this.getField("Signature1");

      s.setAction("Format",