如何在没有下载选项的情况下在Android中从url在线打开pdf? [英] How to open pdf from url online in Android without download option?
本文介绍了如何在没有下载选项的情况下在Android中从url在线打开pdf?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序中,我希望用户阅读我的应用程序中的pdf文件,而没有下载它们的任何选择.我怎样才能做到这一点?我正在使用以下代码,但无法正常工作-
In my app I want the user to read the pdf files inside my app without any option to download them. How can I do this? I am using the following code but not working-
WebView webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setPluginsEnabled(true);
webView.loadUrl("https://docs.google.com/viewer?"+pdf_url);
还有其他方法可以做到吗?如果可以的话?
Is there any other way to do this? If you can do it?
推荐答案
您可以在没有下载选项的情况下在Android中从URL在线打开pdf.
You can open pdf from URL online in Android without a download option.
科特林
val path="https://github.github.com/training-kit/downloads/github-git-cheat-sheet.pdf"
activityWebViewBinding.webview.settings.loadWithOverviewMode = true
activityWebViewBinding.webview.settings.javaScriptEnabled = true
val url = "https://docs.google.com/gview?embedded=true&url=$path"
activityWebViewBinding.webview.loadUrl(url)
Java
String path="https://github.github.com/training-kit/downloads/github-git-cheat-sheet.pdf";
webview.settings.setLoadWithOverviewMode(true);
webview.settings.setJavaScriptEnabled(true);
String url = "https://docs.google.com/gview?embedded=true&url"+path;
webview.loadUrl(url);
这篇关于如何在没有下载选项的情况下在Android中从url在线打开pdf?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文