Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Load PDF / PDF Viewer

Tags:

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.

like image 422
Paresh Mayani Avatar asked Dec 17 '10 07:12

Paresh Mayani


People also ask

Why is my Android phone not opening PDF files?

To fix a PDF file not opening in Adobe reader, you will need to download the latest version of Adobe Reader. After which you will disable the protected mode that comes with it by default. Once this is changed, the issue of the PDF file not opening in Adobe reader will be resolved.

Does Android have a built in PDF reader?

Android has a built in framework from Android 5.0 / Lollipop, it's called PDFRenderer.

How do I view PDF in Android WebView?

The very first and the easiest way of displaying the PDF file is to display it in the WebView. All you need to do is just put WebView in your layout and load the desired URL by using the webView. loadUrl() function. Now, run the application on your mobile phone and the PDF will be displayed on the screen.


1 Answers

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"); 
like image 74
Paresh Mayani Avatar answered Oct 29 '22 02:10

Paresh Mayani