15 Replies Latest reply on Aug 25, 2009 8:15 PM by rich.thibault

    Cannot open PDF files in AIR app on Mac OS

    Jason175

      I am having trouble opening a PDF file in an HTML window on Mac OS.

      My code works fine on any PC, however when running on a Mac, the HTML window shows a white screen when I am trying to load a PDF.

      I have tried several machines, all of which I installed the latest version of Acrobat Reader on before testing.

       

      I also traced HTML.pdfCapatibility, which returns 3201 (Adobe Reader cannot be found.) on all Macs.

       

      My code is below, please let me know if anyone has any ideas...I kind of need this to work asap...

       

      Thanks a lot.

       

       

       

      private function openPDF(stName:String):void{
          //Check PDF compatibility.
          if(HTML.pdfCapability== HTMLPDFCapability.STATUS_OK)
          {             
              //No file to open. Exit with error.
              if (stName == null)
              {
                  pviewError(ERROR_CODE_001, true);
              }
              else
              {
                  var stExt:String;
                  stExt = stName.substring(stName.length-3, stName.length).toLowerCase();
                  //Check for PYM type.
                  if (stExt == TYPE_PDF)
                  {
                      pdfDisplay.location = stName;
                  }
                  //If type not correct, exit with error
                  else
                  {
                      pviewError(ERROR_CODE_002, false);
                  }
              }
          }
         
          //If not PDF compatible, user must download Adobe Reader.
          else
          {
              Alert.show(READER_DOWNLOAD_ALERT,READER_ALERT_TITLE);
              pdfDisplay.location = GET_READER_URL;
          }
      }

        • 1. Re: Cannot open PDF files in AIR app on Mac OS
          __antonio__ Level 3

          What is the path of your pdf? Is it local or through http:?

          • 2. Re: Cannot open PDF files in AIR app on Mac OS
            Jason175 Level 1

            It is a local path.

            The application decrypts pdf files that are encrypted through an application at my company.

             

            It creates a new file (the PDF that is being opened) on the users machine and then opens it in an HTML loader in the application.

            • 3. Re: Cannot open PDF files in AIR app on Mac OS
              Jason175 Level 1

              openPDF is called once the file has been created...

               

              openPDF(fNewFile.nativePath)

              • 4. Re: Cannot open PDF files in AIR app on Mac OS
                __antonio__ Level 3

                check the path structure. It sounds like you might be opening a pdf from a local server (\\mylocalserver) which macs will not read or you might be opening the pdf from the local machine with a absolute path (C:\Documents and Settings\user...). Try using a browseForOpen system or a more relative path.

                • 5. Re: Cannot open PDF files in AIR app on Mac OS
                  Jason175 Level 1

                  Would this explain why I am getting 3201 when tracing HTML.pdfCapatibility, on Macs.

                  • 6. Re: Cannot open PDF files in AIR app on Mac OS
                    __antonio__ Level 3

                    Jason,

                    I apologize for the delayed response. been busy.

                     

                    I further apologize for missing your sentence about the 3201 error in the original post.

                     

                    Were you able to solve your problems?

                     

                    To answer your last question: No, faulty path definition would not display the 3201 error. Your trace should read "0" if Reader is installed. The white box will always show up when you initiate a pdf request through HTML (unless you change the background color, of course).

                     

                    The only way I have been able to reproduce your error on the Mac is by uninstalling Reader altogether, or by installing incorrectly. By this I mean forcing unseen errors on install, which probably wouldn't have happened when you installed Reader. But, you may want to check that Reader is properly installing to the \Applications directories on all your Macs, which doesn't seem like it would make any difference - but you never know sometimes.

                     

                    I recommend building a very simple pdf viewer with traces to test, so as not to interfere with your main application.

                     

                    If you are still having problems, please let me know and I will try to troubleshoot as best as possible.

                    • 7. Re: Cannot open PDF files in AIR app on Mac OS
                      Jason175 Level 1

                      Thanks for the reply. I havent solved the problem yet. I will try your suggestions on Sunday and let you know the results.

                      I did verify that Acrobat reader was installed and even unintalled/reinstalled it... I still got 3201.

                       

                      Just to clarify- From what you wrote, it seems that you have been able to detect Reader, and launch PDFs on a mac, is that correct?

                       

                      Thanks for the help!

                      • 8. Re: Cannot open PDF files in AIR app on Mac OS
                        __antonio__ Level 3

                        Yes, I have been able to open PDFs in AIR on Mac.

                        • 9. Re: Cannot open PDF files in AIR app on Mac OS
                          Jason175 Level 1

                          I discovered that Reader was not being installed correctly on our test machines and corrected that problem, which solved this issue. Thank you for your help.

                           

                          My next question is: What is the smoothest way to allow users who do not have the correct version of Reader to install it? Can the download from Adobe be launched through the browser inside the AIR application? I think I had some trouble while trying to do this.

                          • 10. Re: Cannot open PDF files in AIR app on Mac OS
                            __antonio__ Level 3

                            No, I do not think there is a way you will not be able to initialize the download within your HTMLLoader directly (unless someone else has figured out a way).

                             

                            I suppose you could check which OS version they are on (Windows vs OSX) based on that you can copy the zip directly from Adobe's site and paste it to the desktop while a progress shows. Its a bunch of code writing on your part, and the user would still have to do a little work in installing Reader. Its kind of a pain in the *** and you'd be creating your own download dialog.

                             

                            It would probably be easier to coerce the user to download and install Reader. There are any number of ways to do this. How you do it is up to you.

                             

                            What I would do is if HTMLPDFCapability is anything but STATUS_OK (your else statement) then bring up a pop up explaining the issue with a button to navigate to the Reader Download site in their default browser. Sucky to make them use the default browser, i know, but its easier on you and - from my experience - your co-workers won't really notice or care that it opens the default browser.

                            1 person found this helpful
                            • 11. Re: Cannot open PDF files in AIR app on Mac OS
                              Jason175 Level 1

                              Launching the download site in the default browser would be an acceptable solution.

                              Is it possible to launch an external application (the default browser) via an AIR application?

                              • 12. Re: Cannot open PDF files in AIR app on Mac OS
                                __antonio__ Level 3

                                Not at the present time, unfortunately.

                                • 13. Re: Cannot open PDF files in AIR app on Mac OS
                                  rich.thibault Level 1

                                  Here's how I launch the default browser from AIR:

                                   

                                  navigateToURL(new URLRequest("http://get.adobe.com/reader"),"_blank");

                                   

                                  So how did you fix the bad installs of Adobe Reader?  What was wrong with them?  I'm dealing with this same issue on my Mac now....I keep getting  the dreaded 3201.  I'm actually redirecting the user to download the PDF now as a workaround, when HTMLPDFCapability fails:

                                   

                                  navigateToURL(new URLRequest("file://" + pdfFile.nativePath),"_blank");

                                   

                                  This causes Firefox to ask me if I want to open or save the file.  Kinda kludgey, but better than no file.

                                   

                                  Disclaimer: I'm using SDK 4.0 Beta.

                                  • 14. Re: Cannot open PDF files in AIR app on Mac OS
                                    Jason175 Level 1

                                    I think that the problem was that Acrobat needed to be run to accept the licensing agreement before AIR would recognize it. I was skipping this step when installing.

                                    Try launching acrobat from the applications directory and see if this works for you.

                                     

                                    As far as launching the default browser...While that does work (and is also the solution I decided to use) I have read that it is somewhat unstable and you cannot be sure that all machines will handle this command, although all machines that I have tested on do launch the default browser as I want.

                                     

                                    Let me know if this gets you passed the 3201.

                                    • 15. Re: Cannot open PDF files in AIR app on Mac OS
                                      rich.thibault Level 1

                                      Good call!  That's exactly what it was.  I accepted the license and all is good.

                                       

                                      Thanks,

                                       

                                      rich