3

I have tried to display a PDF file by using a WebView using the following code -

webview.loadUrl("http://www.mywebsite.co.uk/floorplan.pdf");  

or

Uri uri = Uri.parse("http://www.mywebsite.co.uk/floorplan.pdf");    
Intent intent = new Intent(Intent.ACTION_VIEW, uri);  
startActivity(intent);  

Using either I cannot get the PDF to display unless I run it through Adobe (so my app is downloading it), which then looks fine. How can I get the PDF to display using Adobe through my app or am I better off displaying the PDF as an image instead?

Zoot
  • 2,217
  • 4
  • 29
  • 47
user616076
  • 3,907
  • 8
  • 38
  • 64

1 Answers1

3

You'd have to build a pdf viewer to display it inside your app. Your best best is to launch the Intent like you are doing to display it in an external pdf viewer.

Check out this question for more.

Show PDF in Android

Community
  • 1
  • 1
Robby Pond
  • 73,164
  • 16
  • 126
  • 119
  • Thanks for the reply. By external pdf viewer do you mean Adobe? If so I'm not really sure how to call from my app Adobe and pass my pdf as a parameter. – user616076 Feb 17 '11 at 17:12
  • 2
    The intent mechanism is one of the great things (IMHO) in android. In your context, that means: "I want to display (Intent.ACTION_VIEW) something, please someone take care of it". If nobody listens to you (aka: there is no public intent matching your query), you have to explain this to the user. If somebody listens, well, you are done and the pdf is displayed by someone. – tichy Feb 17 '11 at 20:02