繁体   English   中英

在android和IOS phonegap应用程序中读取pdf文件

[英]Reading a pdf file in android and IOS phonegap app

我正在开发phonegap-app 我正在使用网站“build.phonegap.com”来构建 apk(android) 或 IOS(ipa) 文件。 该应用程序基本上只使用html5css3jquery mobilejquery 我在 config.xml 文件中尝试了下面的代码,

<plugin name="com.kernix.pdfviewer" spec="1.1.0" source="pgb" />
我在这里找到的。

在我的 document.ready 在 js 文件中,我写了类似的东西,
window.open('http://www.example.com/foldername/document.pdf', '_blank');
但它不起作用。 我做错了什么吗? 请帮忙,谢谢。

我尝试了下面对我有用的代码,我在这里得到
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');

插件com.kernix.pdfviewer仅在 ios 中支持,在 android 中不起作用。

如果你想在 ios 中使用它,你应该在deviceready事件触发后使用以下 js 代码。

PDFViewer.open("file://sample.pdf","sample.pdf", function (msg) {
    console.log(msg);
});

要在两个平台上阅读 pdf 文件,请使用以下插件

https://github.com/siegfriedbolz/cordova-plugin-file-opener2/tree/dd31ffa

希望对你有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM