How to display .pdf
file inside android webview?
Asked
Active
Viewed 3,595 times
-1
-
Add some 3rd party libraries and open inside your applocation – Naufal Nov 19 '14 at 09:24
-
Check this link http://stackoverflow.com/questions/8814758/need-help-to-convert-a-pdf-page-into-bitmap-in-android-java/16294833#16294833 – Naufal Nov 19 '14 at 09:25
-
Check [this link](http://stackoverflow.com/questions/7437602/how-to-display-a-pdf-via-android-web-browser-without-downloading-first) – Batuhan Coşkun Nov 19 '14 at 09:28
1 Answers
3
Try this snipped:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView webView=new WebView(MainActivity.this);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setPluginState(PluginState.ON);
webView.setWebViewClient(new Callback());
String pdfURL = "http://dl.dropboxusercontent.com/u/37098169/Course%20Brochures/AND101.pdf";
webView.loadUrl("http://docs.google.com/gview?embedded=true&url=" + pdfURL);
setContentView(webView);
}
private class Callback extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(
WebView view, String url) {
return(false);
}
}

MUHAMMAD WASIM
- 191
- 2
- 11