A strange problem in Adobe javascript Calculate event

Explorer ,
Sep 03, 2017

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.

TOPICS
Acrobat SDK and JavaScript

Views

185

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

A strange problem in Adobe javascript Calculate event

Explorer ,
Sep 03, 2017

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.

TOPICS
Acrobat SDK and JavaScript

Views

186

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
Sep 03, 2017 0
Most Valuable Participant ,
Sep 03, 2017

Copy link to clipboard

Copied

Just opening a file does not trigger the calculation events of the fields in it.

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...
Sep 03, 2017 0
Adobe Community Professional ,
Sep 03, 2017

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.

Entering document scripts

https://acrobatusers.com/tutorials/js_document_scripts

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...
Sep 03, 2017 0
Explorer ,
Sep 03, 2017

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?

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...
Sep 03, 2017 0
Most Valuable Participant ,
Sep 03, 2017

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.

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...
Sep 03, 2017 0
Explorer ,
Sep 03, 2017

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??

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...
Sep 03, 2017 0
Most Valuable Participant ,
Sep 03, 2017

Copy link to clipboard

Copied

Yes, that's possible. As its custom calculation simply enter:

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

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...
Sep 03, 2017 0
Adobe Community Professional ,
Sep 03, 2017

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.

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...
Sep 03, 2017 0
Explorer ,
Sep 03, 2017

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.

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...
Sep 03, 2017 0
Adobe Community Professional ,
Sep 03, 2017

Copy link to clipboard

Copied

What happens when you use the stamp?

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...
Sep 03, 2017 0
Explorer ,
Sep 03, 2017

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

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...
Sep 03, 2017 0
try67 LATEST
Most Valuable Participant ,
Sep 03, 2017

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

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...
Sep 03, 2017 0
Adobe Community Professional ,
Sep 03, 2017

Copy link to clipboard

Copied

After the use of a stamp the form fields are flattened.

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...
Sep 03, 2017 0