无法在Android中的inappbrowser中启动pdf文件 [英] Not able to launch a pdf file in inappbrowser in android

查看:495
本文介绍了无法在Android中的inappbrowser中启动pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户点击链接时,我需要在inappbrowser中显示pdf。它在ios工作正常,但不工作在Android。我为我的项目使用IBM worklight。以下是我使用的代码:

I have a requirement to show a pdf in inappbrowser when user clicks on a link. It is working fine in ios but not working on android. I am using IBM worklight for my project. Below is the code I have used:

window.open("pdfURL","_blank","location=yes");

在ios中,inappbrowser启动并显示pdf,但在Android中,inappbrowser启动,但没有显示内容

In ios the inappbrowser launches and displays the pdf but in android the inappbrowser is launches but no content is displayed

推荐答案

不像iOS,它有一个内置的PDF查看器 - Android的webview没有内置的PDF查看器。 >
这是为什么它会在Android中失败。

Unlike iOS, which has a built-in PDF viewer - Android's webview does not have PDF viewer built-in.
This is why it is going to fail in Android.

您在Android中有两个选择:

You have 2 choices in Android:


  1. 使用Google文档通过将文件存储在远程服务器查看文件,并重定向用户,如下所示: window.open (encodeURI('https://docs.google.com/gview?embedded=true&url=http://www.your-server.com/files/your_file.pdf'),'_blank','location = yes ,EnableViewPortScale = yes');

  1. View the file using Google Docs by storing the file at a remote server and redirecting the user like so: window.open(encodeURI('https://docs.google.com/gview?embedded=true&url=http://www.your-server.com/files/your_file.pdf'), '_blank', 'location=yes,EnableViewPortScale=yes');

或使用Cordova插件。例如这一个(您可以在Google中搜索更多)。为此,您需要学习如何在Worklight中创建Cordova插件 a>。

Or use a Cordova plug-in. For example this one (you can search in Google for more). For this, you'll need to learn how to create Cordova plug-ins in Worklight.

您可以在这里阅读更多选项: Phonegap InAppBrowser display pdf 2.7.0

You can read more options here: Phonegap InAppBrowser display pdf 2.7.0

这篇关于无法在Android中的inappbrowser中启动pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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