4 Replies Latest reply on Nov 17, 2008 7:10 AM by (selina_juan)

    Javascript to print print date and time on scanned documents

      I'm using the following code to print a message, time/date stamp, and expiry date along the right hand side of printed documents. It works fine on word docs that were printed to pdf, but when a document it scanned, it mysteriously prints the the correct line of text, but also prints an additional, identical line perpendicular to the original line.

      Any help would be most appreciated!

      // Add field to each page of form
      var inch = 72;

      for (var p = 0; p < this.numPages ; p++) {
      // create rectangle quads for field
      var aRect = this.getPageBox( {nPage: p} );
      aRect[0] = 540.0;
      aRect[1] = 0.0;
      aRect[2] = 576.0;
      aRect[3] = 792;

      var f = this.addField("PrintField" + p, "text", p, aRect)
      f.delay = false;
      f.print = true;
      f.hidden = true;
      f.delay = false;
      f.rotation = 90;
      f.textSize = 10;
      f.textFont = font.HelvB;
      f.textColor = color.red;
      f.alignment = "center";
      f.readonly = true;
      f.value = "";
      }

      var myWillPrintScript =

      'for (var p = 0; p < this.numPages ; p++) { ' +
      'var f = this.getField("PrintField" + p); '
      + 'f.hidden = false; '
      + 'var d = new Date(); '
      + 'var expiryd = new Date(); '
      + 'var ThursdayArray = new Array(7); '
      + 'ThursdayArray[0] = 4; '
      + 'ThursdayArray[1] = 3; '
      + 'ThursdayArray[2] = 2; '
      + 'ThursdayArray[3] = 1; '
      + 'ThursdayArray[4] = 0; '
      + 'ThursdayArray[5] = 6; '
      + 'ThursdayArray[6] = 5; '
      + 'var currentday = 0;'
      + 'currentday = d.getDay(); '
      + 'expiryd.setDate(expiryd.getDate() + ThursdayArray[currentday]);'
      + 'f.value = "This is an unofficial copy of a controlled document. Print date/time: " + util.printd("dd mmm yyyy HH:MM ", d) + " Expires: "+ util.printd("dd mmm yyyy ", expiryd) + " 23:59 EST.";'
      + '}'


      var myDidPrintScript =
      'this.resetForm();'
      + 'this.dirty = false;'



      // Now set the scripts to execute on the Will/Did Print events.

      this.setAction("WillPrint", myWillPrintScript);
      this.setAction("DidPrint", myDidPrintScript);