2

How can I display online PDF in My Phonegap App.

I am trying iframe but PDF is not display any other solution?

I want to display PDF from URL in my App not display in default PDF viewer.

Thanks in advance

Chris
  • 57,622
  • 19
  • 111
  • 137
Krishna
  • 893
  • 1
  • 10
  • 24
  • i guess you need to have a look at cordova InApp Broswer plugin - https://github.com/apache/cordova-plugin-inappbrowser – Gandhi Apr 01 '16 at 09:56
  • but I want to display in my App page between header and footer . How can I do? – Krishna Apr 01 '16 at 10:01

3 Answers3

1

You could use the Google PDF viewer. It embeddeds a PDF given its URL in an online viewer. Then, you just have to use the resulting URL in the iframe src. Change the url query param with the URL of your PDF:

https://docs.google.com/viewer?url=http://www.pdf995.com/samples/pdf.pdf&embedded=true
José Antonio Postigo
  • 2,674
  • 24
  • 17
0

You can use A Document Viewer cordova/phonegap plugin for iOS and Android plugin for showing pdf within you application.

-1

Don't use iFrames on mobile, especially Cordova apps. My suggestion would be to use the InAppBrowser Plugin cordova.InAppBrowser.open('http://linktopdf.com', '_blank', 'location=yes'); (will open the native safari viewer for iOS).

Getting this to work on Android is a bit more complicated. You can use the same approach above but swap _blank with _system. This downloads the PDF to the device through the default browser. 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.

johnborges
  • 2,422
  • 20
  • 33