Android从网址打开pdf文件,并在网络视图中显示diaplay? [英] Android open pdf file from Url and diaplay in web view?
问题描述
我知道这个问题已经问了很多次了,但是我没有得到任何适当而令人满意的解决方案.我想在Web视图中显示Pdf文件,当我单击URL时,它是来自url的pdf下载文件.目前,我正在使用html以下代码在网络视图中显示pdf文件,但它正在打开html文件.自4个小时以来,我一直陷入困境.请向我建议我做错了什么地方.
I know this question has been asked so many time , but i didn't get any proper and satisfactory solution. I want to show the Pdf file in web view , which is coming from the url ,when i click on the URL , my pdf downloads. Currently i am usinghtml following code for showing pdf file in web view , but it is opening the html file. I am getting stuck in this since 4 hours.Kindly suggest me where i am doing wrong.
谢谢.
mWebview.getSettings().setJavaScriptEnabled(true);
WebSettings settings = mWebview.getSettings();
settings.setDefaultTextEncodingName("utf-8");
mWebview.loadData(response, "application/pdf; charset=utf-8",null);
我有以下回复,格式如下:-
i have following response coming in following format :-
**%PDF-1.4%���5 0 obj<</E 74937/H [ 1453 173 ]/L 75330/Linearized 1/N 1/O 8/T 75180>>**
推荐答案
要在Webview中显示pdf,请使用直接网址:
For show pdf in webview use Direct url:
https://docs.google.com/gview?embedded=true&url="PDF_FILE_URL"
现在在Webview中的URL上方加载.
Now load above url in webview.
mWebview.loadUrl("https://docs.google.com/gview?embedded=true&url="PDF_FILE_URL"");
这篇关于Android从网址打开pdf文件,并在网络视图中显示diaplay?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!