These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

How to use a document.open event in acrobat 10.0

The X
Registered: Mar 27 2011
Posts: 24
Answered

I have a script that puts today's date in a text field. It works well but I have it triggered by an Onblur() event. I would rather have it on document open or upon printing the document. But where do I place a script on document level in acrobat 10.0?

My Product Information:
Acrobat Pro 10.0, Windows
maxwyss
Registered: Jul 25 2006
Posts: 255
Just as you would do it in 9.

Open the Pages panel, and select the page on which the document opens, then open the context menu and select Page Properties, and in the dialog opening after that, select the Page Actions tab... and there you are (kind of). FWIW, in older Acrobat versions, that was in the Document menu, directly accessible…

HTH.

Max Wyss.

UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
Accepted Answer
Page-level scripts (as Max describes) and document-level scripts are different things. Page-level actions run when the page is opened, so will run several times as a user moves back and forth through a file. Doc-level scripts only run when the file itself opens, closes, etc.

Doc-level scripts are managed by the Tools Pane > JavaScript panel. If it's not visible, use the tip menu on the top right of the Tools Pane to select it.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
See Entering Document Level Scripts. These scripts execute and are processed when the document is opened. Only the Professional version has full access to editing these scripts.Max has provided a way for Standard users to enter a similar script base on opening pages. If one uses that approach, one might want to include a variable so the initialization script only runs once. Note there will be a lot of added code to the PDF, since the entire script will need to be added to each page open action. If there is only one page it is not a big issue, but on a `10 page PDF it can become more difficult to manage.

George Kaiser

UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
Since the OP is using Acrobat X Pro, it's rather a moot point.

gkaiseril wrote:
...Max has provided a way for Standard users to enter a similar script base on opening pages...
The X
Registered: Mar 27 2011
Posts: 24
UVSAR wrote:
If it's not visible, use the tip menu on the top right of the Tools Pane to select it.
You gotta be kidding me, that was the case, lol.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
UVSAR wrote:
Since the OP is using Acrobat X Pro, it's rather a moot point.
gkaiseril wrote:
...Max has provided a way for Standard users to enter a similar script base on opening pages...
More than the OP will read this. There are many users with standard who's forms would greatly benefit from document level type scripts. One example would be a time sheet that covers a 24 hour a day operation with in an out times since there will be multiple times the time string is converted to a number and those numbers will be added or subtracted and there are special input value validations and changes that would need to be made for the entered values to work properly or allow for special end point processing.

When dealing with a time sheet to cover 24 hours a day operations, there are also scripts that would need to be repeated for adjusting inputted time for 12:00 am, 12:00 pm and Midnight for the end of the same day. Those adjustments would include 12:00 am, 12:00 pm (noon) and 12:00 midnight for the same day, even though this time is actually 12:00 am the next day. JavaScirpt treats 12:00 am and 12:00 pm as 12:00 noon. When one enters 12:00 am the displayed value becomes 0:00 and when accessing the value of the time field, the sting '12:00 am' is the value one sees in JS and this value needs to be adjusted to 0:00 for additional processing with Date object methods. Midnight of the same day is really 12:00 am of the next day, so there needs to be some additional modification of the allowed input string and manipulation of that string to allow for computation of 24 hours for the full day. The largest time value one can enter into a form is 11:59:59 pm, which results in a value less the 24 hours for an entire day.

I have seen versions of Acrobat/Reader that processes the page open actions before the document level scripts are executed. This is not the order one would expect. And this could also cause one to use the open page action besides the document level script action.

George Kaiser