Skip to main content
Participant
Oct 5, 2020 3:47 PM UTC
Question

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

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 is closed to new replies. Start a new post to keep the conversation going.

10 replies

Bernd Alheit
Community Expert
Community Expert
Oct 5, 2020 4:02 PM UTC

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

Translate
Inspiring
Oct 5, 2020 3:49 PM UTC

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

Translate
Participant
Oct 5, 2020 3:55 PM UTC

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

Translate
Inspiring
Oct 5, 2020 4:15 PM UTC

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.

Translate