Rajesh Suthar Rajesh Suthar - 1 month ago 31
Android Question

Load PDF file in webview

I am having webview in my app, i am loading website in my webview and in that website there are multiple links of PDF file but while i am clicking on that it is not opening in webview,
if i am checking it in my windows's browser it opening.
i have enabled javascript but no luck, i used following properties also

webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.setWebViewClient(new myWebClient());

FD_ FD_
Answer

Android does not work like iOS in this respect. The WebView widget cannot display PDF documents on Android.

You will have to:

  • Use a third party library (unfortunately, most open source pdf libs are GPL)

  • Open a pdf viewer app via an Intent

  • Use Google docs in a webview

Comments