19 Replies Latest reply on May 16, 2011 10:01 AM by sandra_chavarria

    "Dynamic Print Date" javascript code in Batch Process

      I am using Acrobat 8 and have found the coding below to put a dynamic print date in the footer area of a document when converting mutliple documents through the batch process. However I can't get it to work, any ideas?

      var inch = 72;
      for (var p = 0; p < this.numPages; p++) {
      var aRect = this.getPageBox( {nPage: p} );
      aRect[1] = .5*inch;
      aRect[3] = aRect[1] - 24; // and 24 points high

      var f = this.addField("PrintField", "text", p, aRect )
      f.delay = true;
      f.textSize = 16;
      f.textFont = font.HelvB;
      f.textColor = color.black;
      f.alignment = "center";
      f.readonly = true;
      f.print = true;
      f.hidden = true;
      f.delay = false;
      }

      var myWillPrintScript = 'var f = this.getField("PrintField"); \r'
      + 'f.hidden = false; \r'
      + 'var d = new Date(); \r'
      + 'var year = d.getYear()+1900; \r'
      + 'var mins = d.getMinutes(); \r'
      + 'if (mins < 10) { \r'
      + ' mins = "0" + mins}; \r'
      + 'if (d.getHours() >= 12) { \r'
      + 'mins = mins + " PM"; \r'
      + '} else { \r'
      + 'mins = mins + " AM"; } \r'
      + 'f.value = "THIS DOCUMENT WAS PRINTED ON "+ (d.getMonth()+1) + "/" + d.getDate()" + "/"+ year + " " + d.getHours() + ":" + mins; \r'

      var myDidPrintScript = 'var f = this.getField("PrintField"); \r'
      + 'f.value = ""; \r'
      + 'f.hidden = true; \r'
      this.setAction("WillPrint", myWillPrintScript);
      this.setAction("DidPrint", myDidPrintScript);