Copy link to clipboard
Copied
I am working with Adobe Acrobat for about 6 years (since the time of acrobatusers.com). I have created thousands of forms with javascript.
Today I faced a strange problem that broke me. I have written this code in a textbox calculate event
app.alert("Hello World");
According to my experience it should show a message "Hello Word" every time the form is opened. But it is not showing any message.
I am on Windows 10 (64 bit) with Acrobat 11 and Reader DC.
I have tried it on my old laptop Windowns 10 (32bit) but the problem is same.
Please, please help me.
Copy link to clipboard
Copied
I am working with Adobe Acrobat for about 6 years (since the time of acrobatusers.com). I have created thousands of forms with javascript.
Today I faced a strange problem that broke me. I have written this code in a textbox calculate event
app.alert("Hello World");
According to my experience it should show a message "Hello Word" every time the form is opened. But it is not showing any message.
I am on Windows 10 (64 bit) with Acrobat 11 and Reader DC.
I have tried it on my old laptop Windowns 10 (32bit) but the problem is same.
Please, please help me.
Copy link to clipboard
Copied
Just opening a file does not trigger the calculation events of the fields in it.
Copy link to clipboard
Copied
If you want a script to run on the opening of a given page then use the "Page Open" event. If you want the script to open when the PDF is opened then use the document level event.
Copy link to clipboard
Copied
Thank you very much.
I am still unable to digest this reply. Actually I am going to create a dynamic stamp and as you know in stamp we have only access to calculate event of stamp textbox. If calculate event of stamp textbox will not trigger ( according to your answer) how will we go further? Second I have created a date field in stamp (javascript in date field calculate event) date is no also changing when I change computer date.
Please help me. Am I missing something?
Copy link to clipboard
Copied
Fields in stamps are even less dynamic than regular fields. They are flattened the moment the stamp is applied and can't be edited (using a script) afterwards.
Copy link to clipboard
Copied
Ok. Can I add a dynamic field in stamp. So that a textbox in stamp has value today's date before the stamp is applied??
Copy link to clipboard
Copied
Yes, that's possible. As its custom calculation simply enter:
event.value = util.printd("mm/dd/yyyy", new Date());
Copy link to clipboard
Copied
You can see examples by looking at the dynamic supplied by Acrobat, do not edit these files.
Dynamic stamp secrets using JavaScript and Acrobat XI by Thom Parker, old but it still applies.
The user stamp directory will not appear until a user creates a new user stamp.
As noted dynamic stamps are only dynamic until placed on the open PDF. The dynamic stamp is a type of annotation.
Copy link to clipboard
Copied
Thank you. I added this code to custom calculation script. After adding code to the field field value is 09/03/2017. I closed the pdf, changed my system data and opened pdf file, but the date is text field is still 09/03/2017. This is the main problem. You can read this post's title again and my 1st question.
Copy link to clipboard
Copied
What happens when you use the stamp?
Copy link to clipboard
Copied
Date on stamp is not changing with system data. In other words calculate event on stamp's date field is not triggering
Copy link to clipboard
Copied
As I told you already, just opening the file does not cause the calculation script to execute. The code I've given was meant for stamp, which will only populate the field when it is applied.
If you want a regular text field (let's say it's called "Today") that updates each time the file is opened place the following code under Tools - JavaScript - Document JavaScripts (not inside a function!):
this.getField("Today").value = util.printd("mm/dd/yyyy", new Date());
Copy link to clipboard
Copied
After the use of a stamp the form fields are flattened.