Previous | Next | (P-PDF) JavaScript
Topic: appOpenDoc Question
Conf: (P-PDF) JavaScript, Msg: 80961
From: klgc
Date: 2/6/2003 12:33 PM
Sorry to take so long to get back to you - I was in the middle of working on a linking problem. I think the results will answer your questions also. So first take a look at the forum thread:
http://www.adobeforums.com/cgi-bin/webx?128@116.MjcDa3cwDVf.3@.1de7ab0d
If you open more than one PDF at a time in a single execution of Acrobat, you are going to have a window for each (just as many applications function). When you close a PDF, its window is gone.
What you do and when you do it is important in JavaScript as the various guides caution. My problem was getting script actions in the right places for smooth linkage transitions.
Besides what is discussed in the above forum thread, the resulting JavaScript I settled on follows:
(you can remove the lines noted as trace)
//=========================================
// from Doc to Link JS action
//=========================================
global.ALtoDoc = "VLtestB.pdf";
global.ALtoDest = "Lvl2LT.indd:B1"; // *** set when link created B1,B2 or B3 ***
global.ALfromDoc = this.path;
global.ALfromPage = this.pageNum;
console.println ("\n LINK from=" + (/\w+\.pdf$/.exec(global.ALfromDoc)) + // trace
" page=A" + (global.ALfromPage + 1)); // trace
console.println ("\n to=" + global.ALtoDoc + " dest=" + // trace
global.ALtoDest); // trace
global.ALtoDoc = global.ALfromDoc.replace(/\w+\.pdf$/, global.ALtoDoc);
global.LinkVariable = true;
app.openInPlace = true;
app.openDoc (global.ALtoDoc);
//=========================================
// to Doc return link JS action
//=========================================
console.println ("\n*** RETURN from page B" + ((this.pageNum) + 1) + // trace
" To=" + (/\w+\.pdf$/.exec(global.ALfromDoc)) + // trace
" page=A" + (global.ALfromPage + 1)); // trace
global.LinkVariable = false;
app.openInPlace = true;
app.openDoc (global.ALfromDoc);
//=========================================
// Common Doc First Page Open JS action
//=========================================
if (global.LinkVariable)
{
//=========================================
// to Doc First Page Open JS action
//=========================================
console.println ("\n*** Doc B first page open JS ***"); // trace
if (typeof global.ALtoDest != "undefined")
{
var Docs = app.activeDocs; // trace
for (var i = 0; i < Docs.length; i++) // trace
{ // trace
console.println ("\nActive Doc[" + i + "]=" + // trace
(/\w+\.pdf$/.exec(Docs[i].path))); // trace
} // trace
this.gotoNamedDest(global.ALtoDest);
delete global.ALtoDest;
var Docs = app.activeDocs;
for (var i = 0; i < Docs.length; i++)
{
if (Docs[i].path == global.ALfromDoc)
{
console.println ("\nActive Doc[" + i + "]=" + // trace
(/\w+\.pdf$/.exec(Docs[i].path)) + " closed"); // trace
Docs[i].closeDoc(true);
break;
}
}
}
}
else
{
//=========================================
// from Doc First Page Open JS action
//=========================================
console.println ("\n*** Doc A first page open JS ***"); // trace
if (typeof global.ALfromPage != "undefined")
{
var Docs = app.activeDocs; // trace
for (var i = 0; i < Docs.length; i++) // trace
{ // trace
console.println ("\nActive Doc[" + i + "]=" + // trace
(/\w+\.pdf$/.exec(Docs[i].path))); // trace
} // trace
this.pageNum = global.ALfromPage;
delete global.ALfromPage;
var Docs = app.activeDocs;
for (var i = 0; i < Docs.length; i++)
{
if (Docs[i].path == global.ALtoDoc)
{
console.println ("\nActive Doc[" + i + "]=" + // trace
(/\w+\.pdf$/.exec(Docs[i].path)) + " closed"); // trace
Docs[i].closeDoc(true);
break;
}
}
}
}
//=========================================
// COMMON DOCUMENT LEVEL JAVASCRIPT
//=========================================
try
{
console.println ("\n*** Common Doc level JS ***"); // trace
if (typeof global.intOpen == "undefined")
{
console.println ("\n*** Initial Doc Open ***"); // trace
global.intOpen = false;
global.LinkVariable = false;
if (app.viewerVersion < 5.05 )
{
throw "Test environment: Acrobat 5.0.5 or Acrobat Reader 5.1";
}
}
app.focusRect = false; // Turn off focus rectangle
app.fs.backgroundColor = color.black; // background color black
app.fs.clickAdvances = false; // no page advance
app.fs.cursor = cursor.visible; // keep cursor visible
app.fs.defaultTransition = "Replace"; // Dissolve page transition
app.fs.escapeExits = true; // Escape exits full screen
app.fs.useTimer = false; // No page timed advance
app.fs.isFullScreen = true; // View full screen
this.layout = "SinglePage"; // Single page layout
this.zoomType = zoomtype.fitP; // Fit page to window
this.disclosed = true;
}
catch (e)
{
app.e, 0);
app.execMenuItem ("Close");
event.rc = false;
}
//=========================================
Hope this helps with your problem.
Regards,
Lee C