3 Replies Latest reply on Mar 4, 2013 3:05 AM by ds garg

    How to open pdf file in Air Application?

    muikyo

      Hi, everybody

       

           I trying to open file pdf from my macbook in Air Application, but it's didn't display anything to me.

      Please help me. I wanna know Adobe Air can open PDF File from Mac or and Window os?

       

      This sample code i used..

       

      var request:URLRequest = new URLRequest("/Users/Morn/Desktop/RD_phase3.pdf");

       

      var pdf = new HTMLLoader();

      pdf.x = 0;

      pdf.y = 0;

      pdf.height = stage.stageHeight;

      pdf.width = stage.stageWidth;

      pdf.load(request);

      container.addChild(pdf);

       

      Thanks a lot,

        • 1. Re: How to open pdf file in Air Application?
          Peter Blazejewicz Level 4

          Hi,

           

          if it didnt' display content - what happens? Is there greyed area in application visible?

          By default Air does not use OS X built-in PDF content support - you need pluggable Adobe solution installed along of AIR runtime.

          Also - you could face issue with path, be advised to use URI based "file://" protocol on OS X (it should work on Windows as well btw),

          Give it a try:

          code:

           

           

          var file:File = File.desktopDirectory.resolvePath("RD_phase3.pdf");

          if(HTMLLoader.isSupported &&

               (HTMLLoader.pdfCapability == HTMLPDFCapability.STATUS_OK) &&

               file.exists)

          {

               // file://{URI}

               var url:String = file.url;

               pdf.load(new URLRequest(url));

          } else

          {

               pdf.loadString("handle errors in user friendly way");

          };

           

           

           

           

          hth,

          kind regards,

          Peter

          • 2. Re: How to open pdf file in Air Application?
            bobbyjimp

            Having basically the same issue.  A blank screen appears.  I am using an iframe to display the PDF file (or trying to)

             

            Windows 7 Professional

            Acrobat Pro X

            AIR 2.7

            AIR SDK 2.7

             

            Code:

            <script>
            function init()
            {
              var out = document.getElementById('outDiv');
             
              if (air.HTMLLoader.pdfCapability ==
               air.HTMLPDFCapability.STATUS_OK)
              {
               out.innerHTML =
                "<iframe src='pdf/newsletter.pdf' width='700' height='500'></iframe>";
              }
              else
              {
               out.innerHTML = "<h2>PDF capability not found</h2> <p>Error is: " + air.HTMLLoader.pdfCapability+"</p>";
              
              }
             
            }
            </script>

             

            I am receiving a 3202 error on return from HTMLLoader.pdfCapability (acrobat version too old)

            • 3. Re: How to open pdf file in Air Application?
              ds garg

              have same problem

               

              i am using flex 4.0, AIR 3.4 and Adobe Reader X(10.14)

               

              unable to load pdf file and throwing error code 3202(i.e. acrobat version too old). anybody can tell whats the actual issue.