Open local PDF file in WebView using Google Docs

拥有回忆 提交于 2019-12-21 04:39:27

问题


There are a million similar questions/answers, all addressing how to open a remote PDF file using Google Docs + webview.

None address how to open a local PDF file.

Given these strings:

String remotePath = "https://myserver.com/data/files/organization/4/pdf/kalinka1369-1374847709-55.pdf";

String localPath = "file:///storage/emulated/0/Droid Noid/com.story.chapters/kalinka1369-1374847709-55.pdf";

String googleDocsURL = "https://docs.google.com/gview?embedded=true&url=";

This works:

webview.loadUrl(googleDocsURL + remotePath);

Whereas this does not:

webview.loadUrl(googleDocsURL + localPath);

I realize there is a space in localPath and I have tried encoding it to no avail:

String encodedLocalPath = "file:///storage/emulated/0/Droid+Noid/com.story.chapters/kalinka1369-1374847709-55.pdf";

Is it possible to open a local PDF file using Google Docs + webview? If so, how?


回答1:


Is it possible to open a local PDF file using Google Docs + webview?

Only if you upload the PDF somewhere on the Internet where Google Docs can access it, or perhaps arrange for somebody else to upload the PDF somewhere on the Internet where Google Docs can access it (e.g., Google Drive).



来源:https://stackoverflow.com/questions/19118822/open-local-pdf-file-in-webview-using-google-docs

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