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

How to open an acrobat search result in an already open pdf document....

moox12
Registered: Apr 6 2011
Posts: 6

Hi all,
 

 
I have this 'start" pdf document with a searchfield in it. This 'start" pdf document lets me search through a few hundred of separated product-pdf's through an indexed PDX file. The search results apear in the Acrobat search pane on the left side.
 

 
So far so good. But, what I like to have is the following: that the pdf from my search results opens in my already open 'start' pdf document. Basicly replacing it with the one from the search pane. (every pdf has a home button, so you can alway's go back).
 

 
I think I need some kind of document script that tells acrobat when it is being opend that it has to open in the pdf that is already active.
 

 
Any help would be great.
 
Dan

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
JavaScript has no control over the search window. JavaScript can be used to setup search parameters and then initiate the search, but access to thee results and how they are displayed cannot be controlled with a script.

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

moox12
Registered: Apr 6 2011
Posts: 6
Thanks Thom,

I am not directly looking to control the search window.

What I need is the following: when I open a PDF document, which has been called on through the search window. That PDF must somehow now that it needs to open in an already opened pdf. This way users can select different pdf's from the search results window, open them, look at them and open another etc. Without having the problem of getting all these opened pdf's on top of each other.

Some kind of little document(pdf) script that tells the document(pdf) not to open in a new window but in the one that is already open.

Thanks again
Looking forward to any hints.



thomp
Expert
Registered: Feb 15 2006
Posts: 4411
There is an Acrobat Preference for opening cross linked documents in the same window. In in the Acrobat Preferences dialog on the "Document" pane. In JavaScript this is the "app.openInPlace" property. It's also a registry setting. So, there are multiple ways to set the preference. The JavaScript code could be placed in a document script on the PDF that is being searched.

However, I don't know for sure that this setting will work for you, but if it does you have a solution.

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

moox12
Registered: Apr 6 2011
Posts: 6
Thom.

Cross linked documents works only if you call on another pdf through a link, button or script..

'app.openInPlace' can be something.

The registry thing is new for me.

Thanks,
Dan
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
They are all the same setting, just accessed in different ways (preferences UI, registry, and JavaScript). And it is the only way in JavaScript to control over where docs open. If it's not applied to the search results, then I don't know what else you could do.

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

moox12
Registered: Apr 6 2011
Posts: 6
Thanks Thom for taking the time. Today I just thought of a another idea: Let's say you put in a document script that when opens, tells all other open pdf document to close. That would be kind of the same thing. The question is of course: how?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The open documents are all listed in the "app.activeDocs" property. But, this property is protected, for a script operating in a document context it will only display the PDFs that are "disclosed". To disclose a PDF add this code to a document level script

this.disclosed = true;

Now the PDF will be visible to scripts in other PDFs, so you can write a loop

for(var i=0;i{
if(app.activeDocs[i]!=this)
app.activeDocs[i].closeDoc(true);
}

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

moox12
Registered: Apr 6 2011
Posts: 6
for(var i=0;i
{
if(app.activeDocs[i]!=this)
app.activeDocs[i].closeDoc(true);
}

i keep getting an syntax error.

ps.this kind of programming is not something i know much about.
try67
Expert
Registered: Oct 30 2008
Posts: 2398
I think Thom meant to write something like this:

for(var i=app.activeDocs.length-1; i>=0; i--)
{
if(app.activeDocs[i]!=this)
app.activeDocs[i].closeDoc(true);
}

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

moox12
Registered: Apr 6 2011
Posts: 6
try67 wrote:
I think Thom meant to write something like this:for(var i=app.activeDocs.length-1; i>=0; i--)
{
if(app.activeDocs[i]!=this)
app.activeDocs[i].closeDoc(true);
}
Super! That one did the trick. You guy's both Rock! For helping me out with this.

In the mean time I was also trying to figure this thing out. Although I haven't the slitest idea what it all means but I know how to puzzle! So I find the following: "http://acrobatusers.com/forum/javascript/newbie-question-about-functions" 2008-02-05 15:16:19

It was meant as an button action but I used it on document level. Works as well.

var d = app.activeDocs;
for( var i in d )
if( d[i] != this ) d[i].closeDoc();
if ( this.disclosed ) this.closeDoc();



I removed something and it worked.

Just For fun I replaced 'this.closeDoc' at the end with 'this.closeOtherDoc'. Seems to be more appropriate but it did not make any difference.



To recap this issue for others as well: When users do a search through all your pdf's and they open several of them, you can close the previeus opend pdf's automatically to prevent a bunch of open pdf's which has to be otherwise closed all separtly. similar with a website when you select a menu item and then another. They switch pages.

To do this make two scripts for the "document-level" (->Document Javascript...).First One:

this.disclosed = true;

(NOTE: If you like to throw a bunch of pdf's on AcrobatPro for editing, better place this one as a "page action" (select the first page from the page preview and r-click for properties, and you get the action pane). Otherwise they wont stay all open in AcrobatPro.)

Second one (from 'try67'):

for(var i=app.activeDocs.length-1; i>=0; i--)
{
if(app.activeDocs[i]!=this)
app.activeDocs[i].closeDoc(true);
}

Or use this one:

var d = app.activeDocs;
for( var i in d )
if( d[i] != this ) d[i].closeDoc();
if ( this.disclosed ) this.closeDoc();



This goes for every pdf!
Again. Many thanks!
try67
Expert
Registered: Oct 30 2008
Posts: 2398
There's no such method as closeOtherDoc(). I suggest not to try and guess what would work, but use the reference provided by Adobe: http://www.adobe.com/devnet/acrobat/javascript.php

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com