简体   繁体   English

在phonegap应用中显示pdf

[英]Display pdf in phonegap App

How can I display online PDF in My Phonegap App. 如何在My Phonegap应用程序中显示在线PDF。

I am trying iframe but PDF is not display any other solution? 我正在尝试使用iframe但是PDF没有显示任何其他解决方案?

I want to display PDF from URL in my App not display in default PDF viewer. 我想在我的应用程序中显示URL中的PDF,而不显示在默认的PDF查看器中。

Thanks in advance 提前致谢

You could use the Google PDF viewer. 您可以使用Google PDF查看器。 It embeddeds a PDF given its URL in an online viewer. 它将URL指定的PDF嵌入在线查看器中。 Then, you just have to use the resulting URL in the iframe src . 然后,您只需要在iframe src使用生成的URL。 Change the url query param with the URL of your PDF: 使用PDF的URL更改url查询参数:

https://docs.google.com/viewer?url=http://www.pdf995.com/samples/pdf.pdf&embedded=true

Don't use iFrames on mobile, especially Cordova apps. 不要在移动设备上使用iFrame,尤其是在Cordova应用程序上。 My suggestion would be to use the InAppBrowser Plugin cordova.InAppBrowser.open('http://linktopdf.com', '_blank', 'location=yes'); 我的建议是使用InAppBrowser插件cordova.InAppBrowser.open('http://linktopdf.com', '_blank', 'location=yes'); (will open the native safari viewer for iOS). (将为iOS打开本机的Safari浏览器)。

Getting this to work on Android is a bit more complicated. 使它在Android上工作要复杂一些。 You can use the same approach above but swap _blank with _system . 您可以使用与上面相同的方法,但是将_blank_system交换。 This downloads the PDF to the device through the default browser. 这将通过默认浏览器将PDF下载到设备。 The second, more involved approach for Android is to download the pdf file to the filesystem through a plugin in the app, and then open it through the default pdf reader. Android的第二种更复杂的方法是通过应用程序中的插件将pdf文件下载到文件系统,然后通过默认的pdf阅读器将其打开

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

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