Skip to main content
Participant
March 28, 2018
Question

Dynamic Print Date with Windows Login ID using Will Print

  • March 28, 2018
  • 1 reply
  • 208 views

I use this code and it worked , I need to add the "Windows Login ID" with the print as " This document was printed on dd/mm/yyyy by User Name" Can you help in this to modify the code.

var inch = 54;

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 )

  1. f.delay = true;
  2. f.textSize = 06;
  3. f.textFont = font.Helv;
  4. f.textColor = color.black;
  5. f.alignment = "right";
  6. f.readonly = true;
  7. f.display = display.noView;
  8. f.delay = false;

}

var myWillPrintScript = 'var f = this.getField("PrintField"); \r'

+ 'f.value = "Printed on " + util.printd("dd/mm/yyyy hh:MM tt", new Date()); \r';

  1. this.setAction("WillPrint", myWillPrintScript);

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
March 28, 2018

[I moved your question from the Forum Comments forum to the JavaScript forum. Why did you post it there?]

First of all, an inch is 72 points, not 54.

You can access the login-name via the identity object, but it requires a privileged context, ie you will need to install a script on the user's local machine to do it.