在Webview中加载PDF文件 [英] Load PDF file in webview
问题描述
我在我的应用程序中具有Webview,我在Webview中加载网站,并且该网站中有多个PDF文件链接,但是当我单击它时,它不在Webview中打开, 如果我在Windows浏览器中检查它,它将打开. 我启用了javascript但没有运气,我也使用了以下属性
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无法像iOS那样工作. WebView小部件无法在Android上显示PDF文档.
Android does not work like iOS in this respect. The WebView widget cannot display PDF documents on Android.
您将必须:
-
使用第三方库(不幸的是,大多数开源pdf库都是GPL)
Use a third party library (unfortunately, most open source pdf libs are GPL)
通过Intent打开pdf查看器应用程序
Open a pdf viewer app via an Intent
在网络视图中使用Google文档
Use Google docs in a webview
这篇关于在Webview中加载PDF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!