Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Adding time stamp to PDFs

Community Beginner ,
May 18, 2023 May 18, 2023

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?

TOPICS
PDF , PDF forms
3.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 18, 2023 May 18, 2023

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 18, 2023 May 18, 2023

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());

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 19, 2023 May 19, 2023

Change the second line to:

if (f.valueAsString=="") f.value = util.printd("mm/dd/yyyy", new Date());

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 19, 2023 May 19, 2023

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 19, 2023 May 19, 2023

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 19, 2023 May 19, 2023

Why is the date not changing to today's date when someone else opens it? What is the wrong in the script?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 19, 2023 May 19, 2023

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 19, 2023 May 19, 2023

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 19, 2023 May 19, 2023

Never mind. I figured it out. 🙂

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 20, 2023 May 20, 2023

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 20, 2023 May 20, 2023
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines