English 中文(简体)
在网络视图中打开一个pdf文件。
原标题:Open a pdf file inside a webview.
  • 时间:2011-02-09 16:24:37
  •  标签:
  • android
  • pdf

我有一个应用程序,我在一个网页上按下按钮,该网页在网络视图中呈现。

现在点击按钮,下载一个pdf文件,然后需要在同一个网络视图中打开该文件。

问题回答

将下载侦听器附加到web视图,并按如下方式更改url。。

“https://docs.google.com/gview?embedded=true&;网址=https://www.实例.com/xxxxxyyyyyxz.pdf“

实例

https://docs.google.com/gview?embedded=true&;网址=https://www.adobe.com/support/products/enterprise/knowledgecenter/media/c4611_sample_explain.pdf

这是一个用来打开pdf而不下载的链接。。。

我希望它能解决你的问题。。

我发现google查看器似乎可以在android浏览器中查看在线PDF文件。您可以建立一个指向PDF的链接,以便在查看器中显示。不过,我还没有尝试在WebView中这样做。

更新

The link is dead, there is an explanation of how to get the functionality to still work at this link.
In case this link also dies, here is the relevant section:

虽然该页面在重定向到谷歌文档/驱动器时不再可用,但您仍然可以使用谷歌文档查看器。将此URL粘贴到新选项卡中:

https://docs.google.com/viewer?url=

然后粘贴要在线查看的文档的地址。下面是一个例子:

https://docs.google.com/viewer?url=http://research.google.com/archive/bigtable-osdi06.pdf

我不认为目前的android chrome浏览器可以支持pdf。安卓论坛上也有关于这一点的讨论(例如:链接1链接2

显示pdf的最佳选择是安装适用于android的adobepdf阅读器。(或者简明扼要地说,在web视图中不可能)

我认为除了Chrome之外,任何浏览器都不支持在没有插件或第三方工具的情况下渲染PDF。让用户使用自己的应用程序打开PDF可能更容易。

I used the IText PDF library mentioned in this thread Android : Is there any free PDF library for Android for a sample project. You could try getting using this API to get the PDF page as an image. I am not familiar with every aspect of Itext so it might have better way to do this.





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签