Skip to content Skip to sidebar Skip to footer

Placing Current Date Into A Text Field Of A Pdf Form Using Javascript

I like to create a PDF which when printed out includes the date and time of when it was printed. Because actually changing the PDF content would require a PDF editor I thought usin

Solution 1:

Yes, it is possible. The PDF documents support a WillPrint action that is executed before the document is printed. You set this action with a javascript action that retrieves the current date and time and sets a field value with this date.

The thing is that not all PDF viewers support Acrobat javascript code so the WillPrint action might not be executed.

Solution 2:

After seeing this post, I wrote an article for our PDF product - Creating Print-Only PDF Content - to show that this is indeed possible. What I have done is create a form field that is hidden on the screen but available when printed. I then added a JavaScript PDF action to the "before print" event of the document so that the form field value was set to the current date and time.

DISCLAIMER: I work for Gnostice.

Post a Comment for "Placing Current Date Into A Text Field Of A Pdf Form Using Javascript"