To display PDF in webview using google doc service in offline mode

半世苍凉 提交于 2019-12-07 08:32:41

问题


I need to display PDF in Webview. I use google doc service to achieve the same (In online mode).

mWebview.getSettings().setJavaScriptEnabled(true); String strPdf="https://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf"; mWebview.loadUrl("https://docs.google.com/gview?embedded=true&url=" + strPdf);

However my requirement is to achieve the same in offline mode. Since google now provides offline support for Google Docs how can I set the url of google Docs for offline mode. Could anyone help me out to achieve this


回答1:


Try this code,It may solves your problem,

WebView webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true); 
String pdf = "http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf";
webview.loadUrl("http://docs.google.com/gview?embedded=true&url=" + pdf);


来源:https://stackoverflow.com/questions/18484549/to-display-pdf-in-webview-using-google-doc-service-in-offline-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!