3 Replies Latest reply on Oct 1, 2009 7:10 AM by Patrick Leckey

    Using OpenDoc to open a pdf in the exisiting window


      I figured out the syntax for opening a document in the same folder with no path.  But it opens it in a new window.  I would really like it to open in the same window as my original document, just like it would if I were to use the "open a file" command and select "existing window".  The reason I'm not just doing that is because I have to create ALOT of PDFs with links to each other and when I copy a control between PDFs it doesn't bring over the actions for the control except for javascript.  If I use javascript, its easy for me to just change one or two names of the file references rather than having to renavigate to all the files I'm linking when I start a new document.


      This is my basic code to open a file:


      app.openDoc("TemplateTest1.pdf", this);


      Its placed on the mouse up event of a control. I thought the "this" part meant this window but I guess it doesn't since it opens the file in a new window.


      The final version of this document will be accessed via internet explorer on a corporate intranet.  when I open the document in internet explorer and execute the openDoc script, it opens the acrobat application as a new window while the original document remains in internet explorer.  I want the new document, which is saved in the same location as the original, to replace the original document in internet explorer.  I have done this before via bookmarks by assigning an open file action and specifying it to open in the existing window.  I just dont know how to specify that instruction in javascipt.


      Or if for some reason this isn't possible.  Can I use the javascript to redirect internet explorer's address to the new document?  If I do it this way I will need to get the address and then replace the exisiting file name with the new file name I want to link to.  Is this possible.  I'm interested in learning about both methods.


      Sorry If Its rediculously basic.  I am just learning javascript specifically for this PDF project.

        • 1. Re: Using OpenDoc to open a pdf in the exisiting window
          Patrick Leckey Level 3

          Working in the browser is completely different from working in the application.  The container is Internet Explorer, which then instantiates the Acrobat ActiveX control to view the PDF, but navigation to different files needs to be done by Internet Explorer if you want to stay in the browser.


          You would have to use JavaScript to redirect internet explorer to the URL of the new PDF.  In order to speak with Internet Explorer from within the PDF via JavaScript, please see the "hostContainer" section of the JS documentation.  This allows you to send messages back and forth between the browser and the document.

          • 2. Re: Using OpenDoc to open a pdf in the exisiting window
            Vanorobat Level 1

            Everything I've read about hostContainer both in the JS documentation and through examples other users have provided indicate that it is mainly used when a PDF is embedded in some other document such as an html web page and you need to communicate between the pdf and the hostContainer the examples i've seen seem to indicate that the hostContainer is the web page itself and not the browser.  My document isn't embedded in a web page, it is simply open using the browser's pdf plug-in.  I've seen another example where someone tried to user app.LaunchURL("www.mywebpage.com/mydocument.pdf").  I tried this aslo but I get the error "Security settings prevent access to this property or method."  All I want is for a new pdf document to be loaded in the same window when the user clicks a button.  I've done this with no problem before when I used the "open a file" action on bookmarks created for each of the PDFs.  And when I set the action I specified "open in existing window".  The actions worked correctly whether the pdf was open in Acrobat Professional, Acrobat Reader, or a Web Browser.   Isn't there an acrobat javascript that does the same thing?  When I did this before I used bookmarks and then used batch processing to add the bookmarks to all of the PDFs so I wouldnt have to recreate them in each one.  This time I want to use buttons to have more screen real-estate and to better control the visual appearance.  I know I could still use the "open a file" action wth a button, I was just hoping there was a javascript alternative so I could have more control over it.

            • 3. Re: Using OpenDoc to open a pdf in the exisiting window
              Patrick Leckey Level 3

              That is correct, in order to use hostContainer your PDF would need to be embedded in an HTML page.  You can set the PDF control to fill the screen so it looks identical to not being embedded in HTML, but this is the only way you can get the document to communicate with its container application - otherwise it will always load in a new window.

              1 person found this helpful