gpt4 book ai didi

javascript - 无法在 android 的 inappbrowser 中启动 pdf 文件

转载 作者:可可西里 更新时间:2023-11-01 02:54:01 25 4
gpt4 key购买 nike

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

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

在 ios 中,inappbrowser 启动并显示 pdf,但在 android 中,inappbrowser 启动但不显示任何内容

最佳答案

与内置 PDF 查看器的 iOS 不同,Android 的 webview 没有内置 PDF 查看器。
这就是它在 Android 中失败的原因。

在 Android 中你有 2 个选择:

  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');

  2. 或者使用 Cordova 插件。例如this one (你可以在谷歌搜索更多)。为此,您需要学习 how to create Cordova plug-ins in Worklight .

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

关于javascript - 无法在 android 的 inappbrowser 中启动 pdf 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26304729/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com