如何启用Web视图加载一个URL以PDF(安卓)双指缩放? [英] How to enable pinch zoom on a web view loading a url with pdf(Android)?

查看:208
本文介绍了如何启用Web视图加载一个URL以PDF(安卓)双指缩放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

双指缩放正常工作在一个web视图加载一个普通的网址,如果我能为下面的设置,

Pinch zoom works fine on a webView that loads a regular url, if I enable the settings as below,

myWebView.getSettings().setBuiltInZoomControls(true); //this works fine.

问题是,

我有一个的WebView加载一个URL以PDF格式。我使用谷歌文档查看器来加载这个URL,以避免下载的PDF到设备。喜欢的东西,

I have a webview that loads a url with PDF. I am using google docs viewer to load this url to avoid downloading the PDF to the device. Something like,

http://docs.google.com/gview?embedded=true&url=http://www.abc.com/xxxxxyyyyyxz.pdf"'

加载该URL的网页视图显示了内置变焦的选择,因为,按一下按钮或双击放大和按钮点击缩小的PDF。

loading this URL on the web view shows the pdf with built in zoom option as, button click or double tap to zoom in and button click for zoom out.

这是不是一个伟大的用户体验相比,双指缩放。

This is not a great user experience as compared to pinch zoom.

到目前为止,我已经尝试了许多解决方案,没有什么工作呢。我曾尝试以下,

So far, I have tried many solutions, nothing worked yet. I have tried the following,

  1. 机器人掐的开源库,它适用于地图和加载一个URL与形象。Web视图
  2. 这<一href="http://www.zdnet.com/blog/burnette/how-to-use-multi-touch-in-android-2-part-6-implementing-the-pinch-zoom-gesture/1847"相对=nofollow>教程是有帮助的,但无法得到它的工作为我的web视图。
  1. android-pinch open source library, it works for maps and web view that loads a url with image.
  2. This tutorial was helpful but couldn't get it working for my webView.

如果任何人有电气特性的有用的信息,我试训,请分享。

if anyone has anyother useful information for me to tryout, please share.

推荐答案

PDF文件是非常困难的,在Android的互动。你可以:

PDFs are notoriously difficult to interact with in Android. You could:

我不建议做这种方式。我的典型逻辑是,如果谷歌没有做它足够长的时间,那么它的无论是很难做到的,或者不是非常的电池效率。在任何情况下,你可能会得到你的手脏了Android NDK,以使您实现快速,高效。

I don't recommend doing it this way. My typical logic is that if Google hasn't done it for a sufficiently long period of time, then it's either very difficult to do, or not very battery efficient. In any case, you may have to get your hands dirty with the Android NDK in order to make your implementation fast and efficient.

http://gurushya.com/customizing-android-webview/

有关这个选项,你就需要分析网页的内容,找到需要的PDF,PDF格式的每张幻灯片转换为位图,并在一个简单的ImageSlider显示每个位图。我还没有时间去尝试这个方法,但似乎它可能工作(可能不是很快,虽然)。这个计算器的答案可以帮助:

For this option, you would need to parse the content of the webpage to find the necessary pdf, convert each slide of your PDF to a bitmap, and display each bitmap in a simple ImageSlider. I haven't had the time to try this method, but it seems like it may work (probably not very quickly though). This stackoverflow answer may help:

<一个href="http://stackoverflow.com/questions/8814758/need-help-to-convert-a-pdf-page-into-bitmap-in-android-java/16294833#16294833">Need帮助PDF页面转换成位图在Android中Java的

这可能是你最好的选择。使用谷歌Docs是一个有点黑客攻击。当你传递一个PDF,你基本上打开了一个JavaScript PDF阅读器与糟糕的移动支持。处理PDF的Andr​​oid中的典型方式是通过检查,如果用户安装了PDF阅读器,并与打开PDF如果他们这样做。这PDF阅读器将很可能有一个捏缩放功能。机器人很可能出于性能原因这种方式实现和各种设备的更广泛的范围工作。

This is likely your best option. Using Google Docs is somewhat of a hack. When you pass it a PDF, you're essentially opening up a javascript PDF reader with lousy mobile support. The typical way of handling PDF's in Android is by checking if the user has a PDF reader installed and opening the PDF with that if they do. That PDF reader will more than likely have a pinch to zoom functionality. Android is likely implemented this way for performance reasons and to work across a broader scope of devices.

请记住,当你的平均的iOS用户可能还不如用这一点; Android用户在其他应用程序很舒服打开文件。打开您的PDF在PDF阅读器为用户提供了选择要使用的PDF阅读器的能力。通过这样做,你给读者更多的选择不仅仅是掐放大(如索引搜索,高亮,快速导航UI),这取决于他们已经安装了应用程序。如果他们没有一个PDF阅读器?推荐一个免费的,它们链接到你的Andr​​oid选择的店!

Keep in mind that while your average iOS user may not be as used to this; Android users are quite comfortable opening files in other apps. Opening your PDF in a PDF reader gives the user the ability to choose which PDF reader to use. By doing so, you give the reader even more options than just pinch to zoom (such as indexed search, highlighting, quick navigation UI) depending on which app they have installed. If they don't have a PDF reader? Suggest a free one and link them to your Android store of choice!

中显示PDF?

这篇关于如何启用Web视图加载一个URL以PDF(安卓)双指缩放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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