Android Display .Doc File in WebView?

我只是一个虾纸丫 提交于 2019-12-01 12:00:22

问题


In my app,I have link http://mymobilece.com/api/api_getexammaterials.php?id=28, I want to view in webview ,I try with google document viewer its work fine But i need it without google document viewer,How to show it??


回答1:


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.



回答2:


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. :)



来源:https://stackoverflow.com/questions/8240294/android-display-doc-file-in-webview

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