9 Replies Latest reply on Mar 12, 2013 11:58 PM by Belle7777

    Obtaining the URL used to open the PDF

    Belle7777 Level 1

      Hi,

       

      My Acrobat PDF is to be opened within the browser using a URL that will differ with each testing region.

      How do I obtain the URL that was used to open the PDF within the PDF javascript code?

       

      Thanks for your help.

        • 1. Re: Obtaining the URL used to open the PDF
          try67 MVP & Adobe Community Professional

          this.URL returns that information.

          • 2. Re: Obtaining the URL used to open the PDF
            Belle7777 Level 1

            Thanks for the response.

            I have already tried this out and I get an undefined value returned. Is there anything else I can try?

            • 3. Re: Obtaining the URL used to open the PDF
              Test Screen Name Most Valuable Participant

              What browser is it opened in? What version of Reader or Acrobat? Is it viewed in the browser window, or the Reader/Acrobat window? What platform?

              • 4. Re: Obtaining the URL used to open the PDF
                gkaiseril MVP & Adobe Community Professional

                You have the path property and the URL property for the doc object. Spelling an capitalization is important in Acrobat JavaScript.

                 

                this.path;

                this.URL;

                 

                but "this.url"is undefined.

                1 person found this helpful
                • 5. Re: Obtaining the URL used to open the PDF
                  Belle7777 Level 1

                  Sorry for the delay in responding.

                   

                  @Test Screen Name: I am using the IE7 browser with Acrobat 9 Pro. Yes the PDF is viewd within the browser window. I am using Windows XP SP3.

                   

                  @GKaiseril: I used this.URL as you have mentioned. I am still getting an undefined value.

                   

                  If this helps, I am trying to get the URL within the docReady event. Could this have any bearing?

                   

                  Also when a PDF is being opened in the browser, is there any way to see the debugger window from within the browser?

                  • 6. Re: Obtaining the URL used to open the PDF
                    Belle7777 Level 1

                    Update:

                     

                    I used event.target.URL and was able to get the correct URL.

                     

                    On a related note, event.target.addWatermarkFromText gives me an error on load as follows:

                     

                    NotAllowedError: Security settings prevent access to this property or method.

                    Doc.addWatermarkFromText:52:XFA:form1[0]:page1[0]:docReady

                     

                    Using this.addWatermarkFromText says there is no such function.

                     

                    Can anyone help on what I am doing wrong? Are there any settings I need to configure?

                    • 7. Re: Obtaining the URL used to open the PDF
                      Test Screen Name Most Valuable Participant

                      Aha! You are using an XFA form (also called a Designer form, because it made in LiveCycle designer).


                      XFA forms use a completely different JavaScript, with entirely separate ways of doing everything, and different things you can do. I very much doubt you could add watermarks, but I can't say for sure - like most people here I don't work in XFA forms. You need to make sure you are using the Designer JavaScript documentation and not the Acrobat JavaScript documentation. (Both the things you have been looking for are Acrobat JavaScript).

                       

                      I recommend using a LiveCycle Designer forum, different group of experts there.

                      1 person found this helpful
                      • 8. Re: Obtaining the URL used to open the PDF
                        George_Johnson MVP & Adobe Community Professional

                        Look at the documentation for that method: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.443.html

                         

                        You'll see that there are security restrictions, so it normally cannot work if the code is inside the document. It also won't work for a dynamic XFA form, but might for a static form if you can get it to execute in a privileged context (e.g., folder-level code).

                         

                        This also isn't something that you'd normally want to do at run-time. Can you explain why you want to do this? There might be other approaches that would be more appropriate for an XFA form, so consider posting this in the LiveCycle Designer forum as TSN urged.

                        1 person found this helpful
                        • 9. Re: Obtaining the URL used to open the PDF
                          Belle7777 Level 1

                          @TSN and George

                          Thanks for shedding light on this. I did not know that Acrobat Javascript varies from Designer Javascript. I am using a dynamic pdf created in LiveCycle. I have taken your advice and posted a question in the LiveCycle forum.

                           

                          @George: Regarding why I want to do this: The PDF will be launched from different servers and as such, the users need to know which server it is launching from (this is for testing purposes). Since this can only be done at runtime, I need to do this. The actual live PDF in the production environment will not show the watermark.

                           

                          Thanks again.