13 Replies Latest reply on Nov 4, 2008 12:02 PM by George_Johnson

    Browser popup window FROM PDF and pass values?

      Hi All,

      I've been researching and can't find whether this is possible or not; would appreciate if anybody has any specific knowledge on this.

      Here is what I'm looking to do:

      1. Load a PDF in the browser
      2. Launch a popup window from within the PDF (i.e. JavaScript, hyperlink, etc.)
      3. Pass a value to the popup (i.e. via querystring? "PopupWindow.aspx?passedVal=xxx")
      4. Perform an operation in the popup window, pass a value BACK to the parent window (that has the PDF loaded) when the popup is closed.

      Obviously this can be done with straight browser windows either by using "showModalDialog" or similar; but the question is can this be done from within Acrobat when the main/parent window as a PDF loaded...

      Thanks!

      Kyle
        • 1. Re: Browser popup window FROM PDF and pass values?
          George_Johnson MVP & Adobe Community Professional
          That might be kind of tough. Would the pop-up window contain an HTML page that submits data to a web server and receives back a response? More details about what you're trying to accomplish might help us suggest reliable alternatives.

          George
          • 2. Re: Browser popup window FROM PDF and pass values?
            Patrick Leckey Level 3
            As long as the popup window is a child of the HTML page and not the PDF then yes, this would be possible. You'll have to use the hostContainer object - here are some good examples of PDFs communicating 2-ways with the HTML page they are embedded in.

            http://www.windjack.com/WindJack/Browser2PDF/brwsr2acroJS.htm

            You would then have a button/link in your PDF that, instead of spawning the child window itself, tells the HTML page it is embedded in to spawn a window. Then use standard HTML/JavaScript techniques to pass data to/from child windows (this part has nothing to do with Acrobat), and use hostContainer again to let the HTML container page pass data pack into the PDF.
            • 3. Re: Browser popup window FROM PDF and pass values?
              Level 1
              Thanks for the response, George. What I'm trying to do here is actually provide an "image gallery" selection tool for users to select an image that resides on the server (i.e. by thumbnail) - and then the corresponding image is updated onto a button icon in the PDF. We already have the image functionality and server-side processes going; the only dilemma is how to present the "gallery" to the user in the PDF itself. The gallery is dynamic and entries are stored in a SQL database (or could be based on file/folder structure) - so obviously adding and maintaining thumbnails in individual PDF documents wouldn't be appropriate.

              So basically the popup window would present the image gallery for selection to the user, and them simply return back the selected image ID or similar to the main window/PDF. So the popup would likely be an ASP page that would query the database and build a grid of available images... If I can get back the ID of the selected image from the popup window - I can take it from there in submitting the PDF to the server, grabbing the appropriate image, and sending the FDF back down to the browser with the image as a button icon.

              Thanks again!
              • 4. Re: Browser popup window FROM PDF and pass values?
                Level 1
                PDL - sounds perfect, exactly what I'm looking for, thanks alot!
                • 5. Re: Browser popup window FROM PDF and pass values?
                  Level 1
                  PDL - any general samples of the actual syntax involved here? I'm not having much luck finding any useful resources other than working implementations... Thanks!
                  • 6. Re: Browser popup window FROM PDF and pass values?
                    Patrick Leckey Level 3
                    What do you mean by 'actual syntax'? Of what, the hostContainer object? There's a section on it in the JavaScript API Reference.
                    • 7. Re: Browser popup window FROM PDF and pass values?
                      Level 1
                      Yes, syntax of sending the script to the hostContainer object. The samples don't seem to show how I'd pass in JavaScript to the HTML page parent. I'm assuming what I'll need to do is execute javascript on the HTML page using hostContainer.postMessage(); but how would I go about sending something like, "window.open()" or "showModalDialog" ? Do I just send the javascript as the regular string message to the HTML page using hostContainer.postMessage? PS: Am I also correct in assuming that this will only work when the PDF is loaded as an OBJECT in an HTML page; not when the PDF is simply opened in a browser window (i.e. typing http://www.website.com/document.pdf" into the address bar...) ?
                      • 8. Re: Browser popup window FROM PDF and pass values?
                        Patrick Leckey Level 3
                        > The samples don't seem to show how I'd pass in JavaScript to the HTML page parent.

                        Yes they do - the sample I linked to shows 2-way communication. From HTML to PDF and from PDF to HTML.

                        > Do I just send the javascript as the regular string message to the HTML page using hostContainer.postMessage?

                        No, you would send a message through postMessage, and have a handler on the HTML page that will execute whatever JavaScript you want based on that message.

                        > Am I also correct in assuming that this will only work when the PDF is loaded as an OBJECT in an HTML page; not when the PDF is simply opened in a browser window

                        Yes, that is correct.
                        • 9. Re: Browser popup window FROM PDF and pass values?
                          George_Johnson MVP & Adobe Community Professional
                          How many images are you talking about being in the image gallery?

                          If I were in your situation, I would dynamically load the thumbnail images into the PDF, perhaps using a separate page, or simulating a popup containing images by using button fields. This would be much more reliable (e.g., less browser compatibility/setup issues) and backwards compatible with the various versions of Acrobat (Reader).

                          George
                          • 10. Re: Browser popup window FROM PDF and pass values?
                            Level 1
                            Thanks again, George. There could be hundreds of images here. I'm considering a scheme where I could actually organize them by category so that I only need to load a few actual images for the respective selected category.

                            Could you elaborate on: "simulating a popup containing images by using button fields"? I think I follow as far as using button fields for image thumbnails - but do you actually mean I could somehow simulate a popup in the PDF?

                            Thanks!

                            Kyle
                            • 11. Re: Browser popup window FROM PDF and pass values?
                              George_Johnson MVP & Adobe Community Professional
                              Yes. Imagine a large button that's normally hidden on a page. When you initiate the "popup", it gets displayed, obscuring (most of) the underlying page. The smaller thumbnail buttons would appear to be on this large button and would hold the thumbnail images that get sent by the server in the FDF. You could have several other buttons to close the popup and request the next set of thumbnails from the server. Make sense?

                              George
                              • 12. Re: Browser popup window FROM PDF and pass values?
                                Level 1
                                I think I'm following you, George. However is it actually possible to lay the smaller 'thumbnail' buttons inside of the larger 'popup' button? How would you pull this off? Thanks!
                                • 13. Re: Browser popup window FROM PDF and pass values?
                                  George_Johnson MVP & Adobe Community Professional
                                  Yes, you just have to set the tab order so that when the large button and the smaller buttons are active (not hidden), the smaller buttons appear to be placed on the larger button, which you would set to read-only so the user cannot click it.

                                  George