13 Replies Latest reply on Aug 29, 2008 6:36 PM by (Bradford_Rogers)

    Script: Open all linked docs in *new* window

      Can anybody help? I have a pdf document that will need to have 2000+ links to other documents...and I need to have each link open in a *new* window (by default, they open in the exisitng window). We obviously don't want to have to individually set each link's Properties to "open in new window"...

      Is there a script I can add to the main (parent) pdf doc to make this happen for all links the user clicks on from the main doc? The kicker is that we can't expect the end user to be able to fool with the Preferences or anything like that...in addition, we assume the user may be viewing in either Acrobat or Acrobat Reader in the corporate environment.

      Alternately, a script to automatically show the "previous view" and "next view" arrows, without having the user have to do anything, might work. The absence of those arrows in the default view (starting w Acro 8?) is why we've had to go with the "open in new window" idea. We are dealing with non-tech-savvy users, so we don't want them to have to know keyboard shortcuts or set Preferences...

      Thanks so much!!!

      Bradford
        • 1. Re: Script: Open all linked docs in *new* window
          Patrick Leckey Level 3
          > Alternately, a script to automatically show the "previous view" and "next view" arrows, without having the user have to do anything, might work.

          Are you in a corporate deployment? Could you not just add the previous and next view arrows to your users default view? I believe there is a registry key for that, you could add it to your deployment MST.
          • 2. Re: Script: Open all linked docs in *new* window
            Level 1
            Sorry, I shouldn't have tried to "simplify" by saying "corporate." This is actually an electronic version of a legal brief with a ton of linked docs, exhibits, etc. It's pretty much dictated to me by the attorneys that this has to be literally "fool-proof". It will be going to a variety of external users via CD-ROM, including the Court, clients, co-counsel, etc...

            That brings up a related concern: what are the odds that a given end user may have Javascript blocked on their machine or network?

            The most elegant solution would be a batch script that could permanently modify each link in my "parent" docs to "open in new window", so it would be "baked in"...

            Thanks so much for the quick response!

            Bradford
            • 3. Re: Script: Open all linked docs in *new* window
              Level 1
              I *think* I have it:

              Given that the doc is set to open on Page 1, I can set Page 1's Action to:

              app.openInPlace = false;

              ...and set document property under DocumentWillClose to

              app.openInPlace = true; (to return to default)

              Seems to work... Hopefully, there won't be many (if any) users of this thing that want their default preference to be "open in new window"...I guess I could create a variable to evaluate and store their initial preference, to be sure we restore it upon closing the doc...?
              • 4. Re: Script: Open all linked docs in *new* window
                (Aandi_Inston) Level 1
                >app.openInPlace = true; (to return to default)

                This isn't necessarily the default or the person's previous setting;
                better to save and restore than to set it to your choice. Better still
                not to change it, and to change each link, but this would probably
                require a custom plug-in to set that.

                Aandi Inston
                • 5. Re: Script: Open all linked docs in *new* window
                  Level 1
                  Absolutely, thanks! I will try to create a variable to store -- and later, restore -- that. Since we have about a zillion links, changing each link would be no fun at all! Is there an issue with trying to evaluate the setting and store the variable from a "on page 1 open" action, and being able to access the variable's value from the "DocumentWillClose" action? (and apologies for any capitalization, etc., issues)

                  Do I somehow need to declare the variable to be global, or do I need to have the initial actions happen from an "on document open" event? (I don't see such an event as being an available option)...

                  Any code snippet(s) far a similar situation that you could point me towards...?

                  Thanks!

                  Bradford
                  • 6. Re: Script: Open all linked docs in *new* window
                    (Aandi_Inston) Level 1
                    > Is there an issue with trying to evaluate the setting and store the variable from a "on page 1 open" action, and being able to access the variable's value from the "DocumentWillClose" action? (and apologies for any capitalization, etc., issues)

                    Well, you may not have been through the "on page 1 open" action, so
                    you do need to recover from that case.

                    For an "on document open" script you would set up a document
                    JavaScript, editing out the procedure header.

                    Aandi Inston
                    • 7. Re: Script: Open all linked docs in *new* window
                      Level 1
                      Uh oh...now we're gettng to the edge of my knowledge. I know a wee bit about JavaScript, but have a semi-decent background with ActionScript for Flash and C++...

                      In this case, I'm not exactly sure where I would go in ACrobat to set up a "document JavaScript," or what procedure header I would edit out. Obviously, I found where to set Page actions in the Page properties, and where to set the "Document Will Close" script, but am stumped on this point.

                      I'm *almost* there, though! If you have a second to elaborate, I think I'll have it. Regardless, thanks for the help! I know you're probably busy, too...

                      Bradford
                      • 8. Re: Script: Open all linked docs in *new* window
                        Level 1
                        Ah, think I got it! I deleted the Page-Level action, and:

                        -went to Advanced>Document Processing>Document JavaScripts...added one called (arbitrarily) "NewWindowScript", deleted "function NewWindowScript()" along with the brackets, and typed in:

                        var x=(app.openInPlace); //hopefully stores the existing value of this parameter
                        app.openInPlace = false; //to cause links to open in new window

                        ...then under Advanced>Document Processing>Set Document ACtions>Document Will Close, I put:

                        app.openInPlace = x; //hopefully restores the previous value upon closing the doc

                        Thanks again!
                        • 9. Re: Script: Open all linked docs in *new* window
                          Patrick Leckey Level 3
                          > //hopefully stores the existing value of this parameter

                          Not in all cases, no. Read the JS API Reference section about global variables (the bookmark is titled "global").
                          • 10. Re: Script: Open all linked docs in *new* window
                            Level 1
                            Yikes. I read it (or did the best I could!), but am not sure why I might need to change anything... I think I see how it might be a best practice; but if I'm only running this one snippet in these .pdfs, it seems like it will work in all but the rarest cases??? I just need the "child" links to open in a new window as long as the main pdf is open.

                            Sorry for my density! Am I at least correct that we don't need to worry about making the variable persistent? And if I'm only dealing with the one variable in this pdf (which I realize could at least be named better), do I really even need to specifically define it as Global?

                            Thanks!

                            Bradford
                            • 11. Re: Script: Open all linked docs in *new* window
                              Patrick Leckey Level 3
                              You don't need to make it persistent, no.
                              • 12. Re: Script: Open all linked docs in *new* window
                                Level 1
                                Ah, thanks so much! I will try to find a decent book on this asap after this project.

                                Bradford
                                • 13. Re: Script: Open all linked docs in *new* window
                                  Level 1
                                  FYI, I mean so I don't have to bother anybody with elementary questions! Aandi and PDL, your help is greatly appreciated. The API Reference is tough sledding for me, without enough background...so I hope I can find a good book that can help fill in the gaps. Thanks for your patience!