简体   繁体   中英

How can i display .docx and .pdf file in webview?

How can i display docx and pdf file in WebView not using url?

Any idea to read document file in android?

try this,

WebView webview = new WebView(this);
setContentView(webview);
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().setPluginsEnabled(true);
webView.getSettings().setJavaScriptEnabled(true); 
webView.loadUrl(url);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM