Dynamic Print Date with Windows Login ID using Will Print

New Here ,
Mar 27, 2018

Copy link to clipboard

Copied

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);

TOPICS
Acrobat SDK and JavaScript

Views

54

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Dynamic Print Date with Windows Login ID using Will Print

New Here ,
Mar 27, 2018

Copy link to clipboard

Copied

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);

TOPICS
Acrobat SDK and JavaScript

Views

55

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Mar 27, 2018 0
try67 LATEST
Most Valuable Participant ,
Mar 28, 2018

Copy link to clipboard

Copied

[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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 28, 2018 0