使用Google文档在WebView中打开本地PDF文件 [英] Open local PDF file in WebView using Google Docs

查看:138
本文介绍了使用Google文档在WebView中打开本地PDF文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一百万个类似的问题/答案,它们都解决了如何使用Google Docs + webview打开远程 PDF文件的问题.

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

没有解决如何打开本地 PDF文件的问题.

None address how to open a local PDF file.

给出以下字符串:

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=";

这有效:

webview.loadUrl(googleDocsURL + remotePath);

而事实并非如此:

webview.loadUrl(googleDocsURL + localPath);

我意识到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";

是否可以使用Google Docs + Webview打开本地 PDF文件?如果可以,怎么办?

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

推荐答案

是否可以使用Google Docs + webview打开本地PDF文件?

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

仅当您将PDF上载到Internet上的某个位置时,Google Docs才能访问它,或者安排其他人将PDF上载到Internet上的某个位置,以便Google Docs可以访问它(例如Google云端硬盘).

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

这篇关于使用Google文档在WebView中打开本地PDF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆