How can I display a pdf document into a Webview?

shriya picture shriya · Apr 16, 2010 · Viewed 189.4k times · Source

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("http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf");

I am getting a blank screen. I have set internet permission also.

Answer

anticafe picture anticafe · Mar 14, 2011

You can use Google PDF Viewer to read your pdf online:

WebView webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true); 
String pdf = "http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf";
webview.loadUrl("https://drive.google.com/viewerng/viewer?embedded=true&url=" + pdf);