2

I want to open pdf in Air for Android/Black berry.

How i do that?

I use AIR 2.6 and IDE is Flash Builder 4.5.

Tahir Alvi
  • 896
  • 2
  • 14
  • 44
  • do you want to parse pdf, or view pdf in your app? – Eugeny89 May 31 '11 at 10:05
  • Tahir I see that you've posted 2 questions in your history and havn't accepted an answer for either one. You should note that it is essential to be a functional part of this community. If you do not accept answers and/or at least upvote people who take time out of their day you assist you, you're going to find people will simply ignore your questions. –  May 31 '11 at 18:09
  • Hi, Thanks for advising, actually i want to open the pdf in the AIR application (Desktop and Android), currently i am use a API that convert pdf to swf and then load into AIR application.But i need to open it directly in the AIR application. Thanks – Tahir Alvi Jun 01 '11 at 04:57

3 Answers3

2

StageWebView.

http://help.adobe.com/en_US/as3/dev/WS901d38e593cd1bac3ef1d28412ac57b094b-8000.html

Example copied from the link above:

package  { 
    import flash.display.MovieClip; 
    import flash.media.StageWebView; 
    import flash.geom.Rectangle; 

    public class StageWebViewExample extends MovieClip{ 

        var webView:StageWebView = new StageWebView(); 

        public function StageWebViewExample() { 
            webView.stage = this.stage; 
            webView.viewPort = new Rectangle( 0, 0, stage.stageWidth, stage.stageHeight ); 
            webView.loadURL( "http://www.adobe.com" ); 
        } 
    } 
}
  • I use this code and run but rather then using stagewebview, i use HTMLLoader to load pdf, but both only load pdf when any pad reader install in the device. – Tahir Alvi Jun 06 '11 at 07:44
1

The StageWebView is the solution #1.

However, this won't work on Android 3 tablets. For activating any plugin (e.g., Flash or PDF) in the StageWebView you need to explictely enable hardware acceleration in the description file. This part would be easy, but Flash CS 5.5 would not package your -app.xml since it checks against the Froyo lib and not the Honeycomb lib. Since the hardwareaccelartion is a feature of Honeycomb, it is unknown for CS5.5.

Here is an immediate need for updating your products Adobe!!!!

So do it with the StageWebView but keep your tablet friends in mind. Give them a message at least.

tom
  • 11
  • 1
  • Take a look at [Adobe's documentation](http://help.adobe.com/en_US/air/build/WSfffb011ac560372f-5d0f4f25128cc9cd0cb-7ffc.html#WS365a66ad37c9f5102ec8a8ba12f2d91095a-8000) on how to do this for Flash and Flash Builder – Colin Jun 13 '13 at 18:46
0

On android if adobe reader is installed this seems to work:

var oFile:File = new File ( File.documentsDirectory.resolvePath ( "filepath/test.pdf" ).nativePath );
var oUrl:URLRequest = new URLRequest ( "file://" +oFile.nativePath );
navigateToURL ( oUrl );

The important and poorly documented part is prepending "file://" to the path.

Trip
  • 1