Copy link to clipboard
Copied
Hi all,
We have a website where we upload PDFs in which users can open, download, print, etc. I would like to add a time stamp to the PDFs that effectively stamps the document with the date when it is opened. That part is easy.....the tricky part is we want the time stamp to not change after it's downloaded. In other words, if I'm a user and I open the PDF today, it will have today's date stamped on it. If I download it today and open it a week from now on my PC I want it to still have the same date I downloaded it. Does that make sense? Is there a javascript for that?
Copy link to clipboard
Copied
Are you doing it using a script, currently? If so, you need to change it so that it only populates the field if it's empty.
If you post the code we can help you adjust it. If you're doing it differently please specify how.
Copy link to clipboard
Copied
Yes. So right now I am using a script to generate the date and then I make it read only. What I would love is if I could add script that would "lock" the date (keep it from changing) if it is saved/downloaded. In other words, if a user downloads the PDF from the site and saves it to their phone/PC, then opens it a week later, the date is the same as when they downloaded it. Right now it would changes to the current day.
Here is the script I'm using:
var f = this.getField("Date1_af_date");f.value = util.printd("mm/dd/yyyy", new Date());
Copy link to clipboard
Copied
Change the second line to:
if (f.valueAsString=="") f.value = util.printd("mm/dd/yyyy", new Date());
Copy link to clipboard
Copied
Thank you! However, what I thought was working doesn't seem to be now. I created this yesterday but when I opened the PDF today it still has yesterday's date on it. What am I doing wrong? I want the date to change when opened but not after downloaded/saved as. Could it be because I'm testing on my desktop?
Copy link to clipboard
Copied
How can the script know if you're opening it on your computer, or on someone else's? If you want to do it like that then add a hidden button that sets the date, and click it after opening the file. You can also use a menu item to do it, but that would require installing a script on the local machine.
Copy link to clipboard
Copied
Why is the date not changing to today's date when someone else opens it? What is the wrong in the script?
Copy link to clipboard
Copied
Nothing is wrong with it. It works as it should, only updating the field when it's empty.
You have to clear the form before sending it to the other person if you want it to update when they open the file.
Copy link to clipboard
Copied
Gotcha. What do mean by clear the form? I clear the date out and send it but the date doesn't update. It stays blank
Copy link to clipboard
Copied
Never mind. I figured it out. 🙂
Copy link to clipboard
Copied
So it works the first time. In other words, I upload the "cleared form" file to Adobe Experience Manager...the date field is blank. The first time me or anyone else goes to the URL it works....it puts today's date. After that, the date never changes again. Even if it's a different user accessing the file. Short of clearing the form every day is there no way around that I guess?
Copy link to clipboard
Copied
This might be a question to the AEM forum... I don't know how it works in terms of serving the file to the users. If you host it on a normal web-server it should work fine, though.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more