Skip to main content
Participant
October 5, 2020
Question

Javascript Print Today's Date Stopped Working - Prints Created Date Instead

  • October 5, 2020
  • 2 replies
  • 820 views

We use javascript on our PDF documents that print today's date. Last week the javascript stopped working and prints the date the PDF was created instead.

Here is the javascript we use:

var f = this.getField("DatePrinted");

        f.hidden = false;

        f.value = "Printed on: " + util.printd("mmm dd, yyyy", new Date());

These are our company's legal documents and the printed date is very important, as the documents are uncontrolled 24 hours after printing.

Could anyone provide assistance to this?

Thank you.

This topic has been closed for replies.

2 replies

Bernd Alheit
Community Expert
Community Expert
October 5, 2020

Use the script at the event "Document Will Print".

Inspiring
October 5, 2020

Where is that code placed, exactly, and what PDF viewer is being used to open the document?

Participant
October 5, 2020

Hi George,

Thank you for your reply. The code is placed in a field called "DatePrinted" and we are using Adobe Acrobat and Reader to open the files. This has worked for us for years, so I'm all sorts of confused as to why it would suddenly print the document's creation date instead. All of our PDFs are now suddenly doing this.

Thanks,

Lynda

Inspiring
October 5, 2020

OK, you told us what field the script is placed in, but not the event (e.g., calculate, validate, format, etc.) The script may not be getting triggered as you expect, depending on where it is placed.