Android Display .Doc File in WebView?

青春壹個敷衍的年華 提交于 2019-12-01 12:24:23
Hardik Gajjar

you can use the js for google Doc viever

myScript="<html><iframe src='http://docs.google.com/gview?

url='http://mymobilece.com/api/api_getexammaterials.php?

id=28'&embedded='true' style='width:600px; height:500px;' 

frameborder='0'></iframe></html>"

mWebView = (WebView) findViewById(R.id.webview);
    mWebView.getSettings().setJavaScriptEnabled(true);

    mWebView.loadData(myscript,"text/html", "UTF-8");

you can use myscript as string variable and use this javascript code(please make sure to remove double quite if above code) and load in webview

  • You can change the url - width- height variables according to your scripting.

Docs.google.com has a document parser , which basically parses MS-Office files , thats why you can view it on google docs. without that you will have to write document parser. Which will parse files and fetch the contents to display on view. In Short it will be not a good idea to do that. :)

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