Copy link to clipboard
Copied
I have a pdf document hosted on my website. I want to be able to have the date added when it is printed and/or saved by an individual after they open it. If they saved the document to their own personal computer, I would like it to have the date on it when they saved it so if they open it again 3 weeks later, it still has the date when they originally saved the document.
Copy link to clipboard
Copied
You can use the document's Will Print and Will Save events to populate a field with the current date, if that field is empty.
Copy link to clipboard
Copied
what does that code look like? This?
var f = this.getField("Today");
f.value = util.printd("mmm/d/yyyy", new Date());
Copy link to clipboard
Copied
Almost. If you only want the field to be populated once then use this:
var f = this.getField("Today");
if (f.valueAsString=="") f.value = util.printd("mmm/d/yyyy", new Date());
Copy link to clipboard
Copied
is it the same for both the Will Save and Will Print events?
Copy link to clipboard
Copied
I would like the date to populate every time it is opened from our website.
Copy link to clipboard
Copied
Yes, it's the same code.
If you want the code to run when the file is opened then you should put it as a doc-level script.
But if you do that it doesn't make sense to put it also in the Will Print and Will Save events, unless you use a different field for each one.