Android - Load PDF / PDF Viewer

I want to display pdf contents on webview.

Here is my code:

WebView webview = new WebView(this); 
setContentView(webview); 
webview.getSettings().setJavaScriptEnabled(true); 
webview.loadUrl("URL/Demo_PDF.pdf");

Problem:

When i am trying to run the application, at that time I am getting blank screen.

And also, if there is any PDF viewer then also suggest me !!

FYI, I have already set internet permission.


Solution 1:

Finally, i got a solution, actually i made a trick to load a pdf file using Google Docs inside a webview:

webview.loadUrl("http://docs.google.com/gview?embedded=true&url=http://myurl.com/demo.pdf");

Solution 2:

I'm sorry but WebView does not display PDF content.
What you might want is a PDF viewer that responds to the PDF MIME type.

Here are a couple of free open-source libraries you might want to check:

  • droidreader
  • apv pdf reader

Solution 3:

You can try using mupdf (www.mupdf.com) You can build a native code library (libmupdf.so) to be loaded onto your android project using the ndk. This would ensure a lot faster rendering of pdf files... check out the project at : http://mupdf.com/repos/mupdf/android/

Solution 4:

WebView does not have a PDF plugin. You should store the PDF locally and open an intent for viewing that kind of content.