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

Toolbuttons Fonction

mike_zet
Registered: Feb 4 2008
Posts: 7

Hi, I'm looking for some help with my Toolbutton. I know how to create one embedded in to specific Document but I can't set a function that will perform "Go To Page in Another Document". If someone know the answer I will be very grateful for your help.

My Product Information:
Acrobat Standard 7.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
To "goto" a page in another document you have to first open the other document, so it's a two step operation.

var oDoc = app.openDoc(...);
oDoc.pageNum = ...;

The other document must be "disclosed" in order for a script in another PDF to use it. Place this code in a document script:

this.disclosed = true;

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

mike_zet
Registered: Feb 4 2008
Posts: 7
Ok I managed to open another document but I still can’t go to specific page in that opened document. I’m getting massage:

TypeError: oDoc has no properties
5:Document-Level:openffs

This is happening when I try to execute Document level script “openffs()” from toolbar button. I’ve created this toolbar button in Page level script:

app.addToolButton({
cName: "Return",
cExec: "openffs()",
cTooltext: "Return",
nPos: -1
});

and the function looks like this:

function openffs()
{var oDoc = app.openDoc({
cPath: "/C/mike/ffs/data/ffsdemo.pdf"
})
oDoc.pageNum = 2;
}

When I execute the same function “openffs” from console it works fine. So I’m guessing that the function is ok but there is something wrong with toolbar button creation.

Closing of the first document also produces problems. When I try to execute function “this.disclosed = true;” from toolbar button the whole application crashes. When I use console it works fine.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
The statement "this.disclosed = true;" has to be a document level JavaScript in the PDF you are going to open by the use of JavaScript. This statement has to run in the PDF being opened at the time that the PDF is opened.

From the JS API Reference:

"This property indicates whether the document should be accessible to JavaScripts in other documents. Only documents with disclosed set to true are included in the app level activeDocs array. The app level method openDoc will only return the Doc Object if the target document has disclosed set to true in a document level JavaScript otherwise it returns null."

George Kaiser