使用Google文档在webview中显示pdf文件(存储在谷歌驱动器中) [英] Display the pdf file(stored in google drive) in webview by using google docs

查看:255
本文介绍了使用Google文档在webview中显示pdf文件(存储在谷歌驱动器中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的pdf文件存储在某些网站上,例如:



我应该做些什么以便我可以使用自己的pdf从谷歌驱动器在webview中打开



我遵循 CommonsWare Stuart Siegler Samir Mangroliya 但没有任何效果。
:(


解决方案

使用Google文档即可在互联网上查看任何pdf,甚至不需要将其下载到设备。这里是如何做到这一点的示例:

  webview.loadUrl(http://drive.google.com/viewerng / viewer?embedded = true& url =+ pdf); 

其中 pdf 是一个到你的PDF文件的字符串链接,所以你的情况就是:

 字符串pdf =http://www.pdf995.com/samples/pdf.pdf; 
webview.loadUrl(http://drive.google.com/viewerng/viewer?embedded=true&url= + pdf);


My pdf file is stored in some website ex: http://www.pdf995.com/samples/pdf.pdf

Now I can't rely on other websites for my app. So

  1. I've downloaded the pdf doc
  2. uploaded in google drive
  3. Got my own link for pdf
  4. Trying to open that in webview using google docs
  5. FAILED

Now the links are as follows

Result,

  • Other websites may change their url at anytime. Can't rely on it.

  • If I use the google drive link alone, then it is opening in web browser not within the app.

  • If preceded with google docs, it is not resulting in a pdf doc. I get something like this.

What should be done so that I can use my own pdf from google drive to open in webview

I've followed CommonsWare, Stuart Siegler, Samir Mangroliya But nothing works. :(

解决方案

you can view any pdf on the internet using google docs even without downloading it to the device. Here is the sample of how to do it:

webview.loadUrl("http://drive.google.com/viewerng/viewer?embedded=true&url=" + pdf);

Where pdf is a string link to your PDF file. So in your case it will be:

String pdf = "http://www.pdf995.com/samples/pdf.pdf";
webview.loadUrl("http://drive.google.com/viewerng/viewer?embedded=true&url=" + pdf);

这篇关于使用Google文档在webview中显示pdf文件(存储在谷歌驱动器中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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