• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

How to open a native PDF file in Android using AIR?

New Here ,
Jun 24, 2012 Jun 24, 2012

Copy link to clipboard

Copied

Hello.I have created a flex mobile project to open and show a native PDF file in Android. I have tried three different methods below , but  I failed.

1. I created a stagewebview and used "stageWebView.loadURL". I can see the PDF View in emulator but it didn't work in Android Pad (SAMSUNG Galaxy Tab 10.1). It showed blank screen.

Note that I have installed AIR 3.3.

stageWebView1.loadURL(new File(new File("app:/assets/ZUGH-2P.pdf").nativePath).url);

2. I created a stagewebview and used stagewebview to load javascript. The javascript could run in emulator, but it didn't work in Android Pad. I failed again.

stageWebView1.loadURL(new File(new File("app:/assets/JavaScripthtml.html").nativePath).url);

3.  I imported stagewebviewbridge, which is the extended version of stagewebviewbridge. I created a stagewebviewbridge , but it could not run in emulator. I failed again.

stageWebViewbridge1.loadLocalURL( "appfile:/assets/pdf.html");

could any one give me some suggestions? Many thanks.

TOPICS
Development

Views

7.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 25, 2012 Jun 25, 2012

Copy link to clipboard

Copied

I don't think Android supports that functionality.

Try opening any PDF on the web with the browser on an Android device, it will download the PDF instead of displaying it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

I think that @PierreSolutions is correct. Does your app exhibit that behavior (that is, does it download the PDF?) when running on the device?

Regards,

Randy Nielsen

Senior Content and Community Manager

Adobe Systems Incorporated

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

Many thanks for your reply!

I just want to open a native PDF file rather than a remote one .

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 27, 2012 Jun 27, 2012

Copy link to clipboard

Copied

Dear jrunrandy,

I have work on this problem for a long time.But I was unable to

solve it. How can I open a native PDF file? The browser showed that

file path was incorrect. How can I  form the right file path?My

codes are below.

navigateToURL(new URLRequest("app:/assets/ZUGH-2P.pdf"),"_blank");

It worked very well in emulator, but failed in Android Pad.

I noticed that you are an employee of  Adobe company.

Could you please give me some suggestion in detail? Thank you very

much.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jun 27, 2012 Jun 27, 2012

Copy link to clipboard

Copied

@peterpan_cafuc,

Sorry to say that I'm not sure of the answer, either.

One suggestion would be to try something like File.openWithDefaultApplication(), although I've never tried it on mobile.

Also, I poked around stackoverflow, and it looks like people have done this using Android Intents, but you might have to use a Native Extension  to do this in AIR.

Apologies that I can't be more helpful.

-Randy

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 27, 2012 Jun 27, 2012

Copy link to clipboard

Copied

Dear Randy,

I have tried the methods above, but failed.

Thank you for your help anyway.

Regards,

Peter Pan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

Has anybody found a solution to this problem? Thanks, Neil

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 21, 2012 Sep 21, 2012

Copy link to clipboard

Copied

I think the solution is an Android Native Extension to which you pass the path and file name. It would in turn call Android's file handling routines which would trigger the dialog asking which application should be used ... or if one was already associated with that file type, it would launch it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 26, 2012 Sep 26, 2012

Copy link to clipboard

Copied

I found such an extension here http://activeden.net/item/document-launcher-native-extension-for-android/2015733 I have not tried it and can't vouch for it, but it seems to do what you are looking for.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 08, 2014 Mar 08, 2014

Copy link to clipboard

Copied

LATEST

I know it has been a very long time, but air on android still does not allow PDFs opening on the device. I have used the above ane and just wanted to provide an update for anyone else seeking info..

That ane does open PDF files as long as there is a reader available. It is also very easy to implement using two lines of code, or two lines and a basic function to tell the user that it needs a reader installed.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

Thanks a lot!

I have tried your method, and I used "navigateToURL" to open the web with the browser. I could open a remote PDF file in http website.

Unfortunately, I could not open the native PDF file.

The codes are below.

navigateToURL(new URLRequest("app:/assets/ZUGH-2P.pdf"),"_blank");

It worked well in emulator, but failed in Android Pad. The OS alerted "file path error".

Is anything wrong in my codes?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines