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

How to run a script at Doc/Open Event?

asmohr
Registered: Sep 2 2007
Posts: 25

Hi folks,

I need some help with event triggers.

In the Acrobat JavaScript Scripting Reference there are 6 Doc events which
are described similarly:
Doc/DidPrint
Doc/DidSave
Doc/Open
Doc/WillClose
Doc/WillPrint
Doc/WillSave

In the Advanced > JavaScript > Set Document Actions... tool there are
only 5 events. The Document Actions dialog will not let you set a script
for the Doc/Open event. The Reference does not mention any differences
in how these events are triggered or operate.

So is it possible to set a script to run at the Doc/Open event, or is the
Acrobat JavaScript Scripting Reference simply being overly optimistic?

It would be useful to me to have a script that automatically executes
at Doc/Open. The Adobe doc implies that it's possible by having an
entry in the Reference for it.

But how do you do it?

Any suggestions are most welcome.

Thanks,
August

P.S.
To be symmetrical, the name of the event should probably be Doc/DidOpen.
-A

lkassuba
ExpertTeam
Registered: Jun 28 2007
Posts: 3636
You can add a Doc/Open event by using either a document script (Advanced -->Document Processing --> Document Javascript) or a Page Open Action (Pages Navigation panel -->Right click the first page icon in the Navigation panel then click Page Properties, click the Action tab. Insert the JavaScript for the Page Open action.)

Lori Kassuba is an AUC Expert and Community Manager for AcrobatUsers.com.

arnoldspaeing
Registered: Oct 2 2007
Posts: 3
Hi,
how can I execute a folder-level script by an Doc/Open event?
Arnold
lkassuba
ExpertTeam
Registered: Jun 28 2007
Posts: 3636
You place the javascript in the config.js folder and then reference it in your script at the doc/open event. There is an example of how to reference a folder-level script in the Developing Acrobat Applications Using Javascript at:
http://www.adobe.com/devnet/acrobat/pdfs/js_developer_guide.pdf

Lori Kassuba is an AUC Expert and Community Manager for AcrobatUsers.com.

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
If you use the folder level script, you may have to have all users add the folder level script to their system's Acrobat/Reader application's JavaScript folder.

To execute a folder level script at anytime besides the application initialization, you have to write the script as a function and you can then call the function as a document level script (run upon opening the document) or as any other action. If you chose to use a page open action that is to be executed only once, you will have to add extra code to prevent it's re-execution each time the page is opened.

George Kaiser