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());
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
this may help you,
String myPdfUrl = "http://example.com/awesome.pdf";
String url = "http://docs.google.com/gview?embedded=true&url=" + myPdfUrl;
Log.i(TAG, "Opening PDF: " + url);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With