Expand my Community achievements bar.

How to switch operational focus to the next document tab?

Avatar

Level 1

Hi,

I am new to JavaScritp as well as the JavaScript API. My end goal is to create a button that will take each page of the currently active document and insert it after the last page of each document in the list. It seems that  app.activeDocs.bringToFront();  and  app.execMenuItem("GoForwardDoc")  only change the current view, not the application's operational focus. Does anybody know of any way to change operational focus?

While writing the code I have set it to not repeat. Currently, it inserts each page of the source into itself even though it should re-run documentFileName+"";

var docs = app.activeDocs;

var source = this.documentFileName;

//var target = app.execMenuItem("GoForwardDoc"); + documentFileName+"";

console.println('The source is ' + source);

if (docs.length <= 1){

app.alert("You must have at least 2 PDF's open for this operation.");

}

else{

app.execMenuItem("GoForwardDoc");

console.println("You are now looking at the target document");

documentFileName+"";

console.println("the target document is " + this.documentFileName);

this.insertPages({nPage:this.numPages-1, cPath: source});

}

This is an older sample - I continued to work on this at home from my laptop to call a function 'getDocName' but the results were identical.

Consol prints:

The source is Doc1.pdf

You are now looking at the target document

the target document is Doc1.pdf

undefined

0 Replies