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

Access doc object from folder level javascript

ulrike73
Registered: Jul 23 2007
Posts: 22

Hi there,

maybe this question is too stupid. But I don't see how to get out of this:

I need to access the doc object of the pdf file, that is in front, from a
folder level javascript.

By using app.activeDocs I only get the list of all open files but no hint,
which one is in front.

And by knowing a doc object I can execute the brintToFront() method
to send a pdf file to the front.

Is there a way for doing this?

Ulrike

Clivel
Registered: Jan 11 2007
Posts: 6
Hi,
You may find simply using the 'this' document object gives you the uppermost document.
Rgds
Clive
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You can use the element of the returned active doc array as shown in JS Scripting Reference for the "bringToFront()" method:

This example searches among the open documents for one with a title of “Annual Report” and brings it to the front.

var d = app.activeDocs; // get array of open docs
// loog throgh the open doc array
for (var i = 0; i < d.length; i++)
if (d[i].info.Title == "Annual Report") d[i].bringToFront(); // for doc object titled "Annual Report" bring it to the front

George Kaiser

ulrike73
Registered: Jul 23 2007
Posts: 22
Hi clivel,

thanks for your quick reply.

Unfortunately, I am trying to build a sort of structure of objects and methods in order to enrich the UI. Thus, I created one global object, i.e. namespace, to avoid messing around with to many objects on the global level. All functions and further objects are located inside this global object. But now I see, that I am loosing "this".

Thanks again. I see the point now.

Ulrike
ulrike73
Registered: Jul 23 2007
Posts: 22
Hi gkaiseril,

yes, I know this example.

But unfortunately, I don't now any property of the doc object I am searching for exept that it is displayed on top of all others.

Is there a property reflecting this?
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Well then you will have to provide a JS action to display a list of all the active documents and the "documentFileName", "URL", or info.title" property using the "app.response()" method to get the element number for the document in the active document array and use that element.

Edited to add:
The "bringToFront()" method only change the PDF "this" and not the display. To change the display one would need to provide an additional action like go to a specific page or form field on the focused document.

George Kaiser

ulrike73
Registered: Jul 23 2007
Posts: 22
Hi gkaiseril,

thanks again. I will have to try it this way.

In any case, many thanks for the nice discussion. It was very helpful

Regards, Ulrike