Future Date

Oct 22, 2020

Copy link to clipboard

Copied

I want to calculate the future date from todays date plus x number of days. Never having used Java Script before what steps do I follow to incorporate the calculation into the PDF Document. When I attach the PDF Document to an email I don't want the field to be updated for the recipient but remain effectively at the original date. It represents the expiry date on a Membership Card and we don't want it to change each time the recipients opens the attachment.

TOPICS
Acrobat SDK and JavaScript

Views

53

Likes

Translate

Translate

Report

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

Future Date

Oct 22, 2020

Copy link to clipboard

Copied

I want to calculate the future date from todays date plus x number of days. Never having used Java Script before what steps do I follow to incorporate the calculation into the PDF Document. When I attach the PDF Document to an email I don't want the field to be updated for the recipient but remain effectively at the original date. It represents the expiry date on a Membership Card and we don't want it to change each time the recipients opens the attachment.

TOPICS
Acrobat SDK and JavaScript

Views

54

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 22, 2020 0
Oct 22, 2020

Copy link to clipboard

Copied

So when do you want it to update, exactly? If only once then you can just fill it in manually. If you want to do it using a script you can run it from the JS Console, for example.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 22, 2020 0
Oct 22, 2020

Copy link to clipboard

Copied

When a new member joins our organisation they are sent an email with the temporary memberhip card attached. The cardhas to be good for a number of days (to be determined) before they receive their annual membership card. I can do it manually but that means each day I have to update the expiry date (todays date plus x number of days). Can Java Script each day do this calculation automatically and ensure it can't be changed when new member opens the attachment

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 22, 2020 0
Oct 22, 2020

Copy link to clipboard

Copied

No, it can't do it by itself. Something has to trigger it, such as opening the file, or pressing a button, or something like that.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 22, 2020 0
Oct 22, 2020

Copy link to clipboard

Copied

Not sure what you mean but of course the new member has to open the file to see and print their temprary membership card. I need someone to produce the java script.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 22, 2020 0
Oct 22, 2020

Copy link to clipboard

Copied

But you said you didn't want that to cause the field to update. So the question is, what should?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 22, 2020 0
Oct 22, 2020

Copy link to clipboard

Copied

Member Smith opens the attachment on 22 October and for example the expiry date is 27 October. Member Smith opend the attachment on 23 October it still says the expiry date is 27 October. He opens it on 24 October it still says 27 October and so on.

Member Jones also opens the attachment on 22 October and has the same experience as Member Jones

Member Harry opens the attachment on 23 October with an expiry date now 28 October (future date is 5 days in advance of todays date). Member Harry still sees 28 October as the expiry date each time he opens the attachment.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 22, 2020 0
Oct 22, 2020

Copy link to clipboard

Copied

Ideally, the server script that sends the PDF should be setting the date on the card. This ensures the date is set properly and cannot be changed by the user.  This requires purchasing a tool or paying for some development.

 

You are thinking that a script on the PDF could solve this problem easily with little expense? This is only partially true.

The first problem is that the user would be required to open the PDF in a viewer that can execute JavaScript. Preferably  Acrobat Reader. Unfortunately, most mobile PDF viewers are useless in this area. 

The second problem was outlined by Try67, you need a one time trigger to run the date script. If the trigger is repeated, the date will be updated every time the trigger is hit.  

Both of these issues can be solved. The trigger issue can be partially solved by using the state of the expiration date field to decide whether or not to set the date. But this is weak solution because it only works if the user saves the PDF with the date set. 

 

  

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 22, 2020 0
Oct 22, 2020

Copy link to clipboard

Copied

I'm sorry, but that doesn't answer my question. I know when it shouldn't be updated. The question is, when should it? And how? Just sending the file can't do that. It has to either be opened (so the script can execute) or otherwise edited with an external tool before being sent.

If you open the file in Acrobat and email it from there then it could be possible, as long as you don't overwrite the local file, or at least save it under a new name.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 22, 2020 0
Oct 22, 2020

Copy link to clipboard

Copied

This is the process. When a member joins the system automatically sends a welcome email. Attached to this email will be the membership card. When received by the member it will be opened. That is the first time the attachment is opened giving the correct expiry date as mentioned before. I have no understanding of Java Script and Adobe Acrobat Pro for this application. I am looking if possible for someone to produce a PDF File that when opened by the Member would produce the expiry date desired. If this is not possible or the member opening the file has to also have Java Script installed and Adobe Acrobat Pro then it is a non starter and I will do it manually which I can do and proven it works.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 22, 2020 0
Oct 23, 2020

Copy link to clipboard

Copied

But why would the member opening it be different from YOU opening it? What if they don't save it, but open the attachment again, starting the whole process again? Certainly this won't work if it's based on the member doing it, because it might not be saved. It HAS to be done before sending.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 23, 2020 0
Oct 23, 2020

Copy link to clipboard

Copied

Exactly. It has to be done either on the server (not using Acrobat), or by someone manually. If you send a file with a script to populate the field and the user doesn't save it, it will display a different date each time they open it, defeating the purpose.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 23, 2020 0
Oct 23, 2020

Copy link to clipboard

Copied

Thank you for taking the time to look at the problem

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 23, 2020 0