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

Open Document JavaScript Action

whatever
Registered: Aug 23 2007
Posts: 21

Hello,
 
I need to run a script when the document is opened. Unfortunatelly the list of document actions dos not include something like "Document Did Open". How should i bind my script with that event?
what i need to do is to show the date&time at the top of the document every time it is opened by a reader.
 
We are using Acrobat Standard 6.0
 
Any hint is appreciated.
 
Thanks in advance

My Product Information:
Acrobat Standard 6.0.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
This can be done with either a document script or page open Action.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

whatever
Registered: Aug 23 2007
Posts: 21
Thom, thank you for your answer.

With the support of Eugene Williams i know how to attach a script to a page open action.

Would you please tell me how can I attach a document script using Adobe Standard 6.0

I've searched the entire menu options and nothing.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Eugene says that you can add a document script from the Advanced toolbar, but I didn't think that Standard 6 had a menu item for this. If I'm right, then there is a workaround, it can be done from a script. Since you are using Acrobat 6 the solution is bit awkward.

Lookup the "doc.addScript()" function in the Acrobat JavaScript Reference. This will do the Job, and there are two ways you could use it.

1. If you want to get really fancy, or you want to do this a lot, write a folder level script to add a menu item (or toolbar button) to Acrobat. Place a function in this script for adding a document level script to the current PDF, then call this function from the menu item.

2. Put the code for creating a folder level script in a Page Open Action. Force it to run by changing pages, then delete the Page Action and save the file.

Here's a sample script that adds an alert box script. The alert box will be displayed when the PDF is opened.

var myJS = "app.alert('Hello World');";
this.addScript("InitMsg",myJS);

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script