Do download the file and use the fileopener plugin for android phonegap apps as explained in this stackoverflow answer. I had the same problem as the op and many unsuccessful approaches later i came to the following solution tested with cordova 3. I know that pdfs, in general, just work on both android and ios, but i was specifically curious about how you would use pdfs within a cordova. This plugin offers a slim api to view pdf files which are either stored in the apps assets folder. Follow platform specific guides to install additional platform dependencies. Open a command prompt or terminal, and type npm install g cordova. Because of how cordova works we need the cordova plugin file, the cordova plugin file opener2 and file saver. Downloading and opening a pdf in phonegap on an android unit seems to be opone of the hardest things you can nowadays, that and maybe copy files to my samsung galaxy tab 10. Download them to a temp folder before starting the viewer. Previous post how to download and open a pdf on phonegapcordova.
The base64 string will be processed and converted into a writable blob. Apparently downloading and opening a pdf in phonegap cordova seems to be one of the hardest things to, but not anymore. This is a newish html5 feature that tells the browser that it should download the asset instead of trying to. Follow the link below, download the cordova plugin of the pdf reader for free. Example file download and open in cordova inappbrowser example download andopen. Contribute to pwlincordova pluginfileopener2 development by creating an account on github.
Devrel at large, star wars nerd, webserverless hacker, lover of good beer and good books. Thanks for contributing an answer to stack overflow. It also lets the user open the files in a webview and polyfills the anchors download attribute. I want to open pdf file from url within app screen without open any inappbrowser or external app please tell me is there is any solution for this. The cordova file writer provided by the cordova file plugin doesnt support write files with base64, therefore we are going to use a little trick. This plugin offers a slim api to view pdf files which are either stored in the apps assets folder or in any other file system directory available via the cordova file plugin e.
Pdf document viewer cordova plugin for ios, android and windows 8. In this example, we will show you how to create file, write to file, read it and delete it. How to save a pdf from a base64 string on the device with. Contribute to pwlincordova plugin file opener2 development by creating an account on github. This will either open the file in the installed pdf reader or present the user with a. Example file download and open in cordova inappbrowser. This plugin tries to open a file in a local viewer. Phonegap how to download and open pdf file in android app stack. We need to run the following code in the command prompt to install this plugin. The cordova plugin file plugin gives us access to the userss file system, and the cordova plugin file opener2 plugin helps us with. Then we zip it, run through phonegap and then download and open.
124 1132 123 1400 847 444 797 1537 569 131 1077 273 788 425 1375 422 623 1409 1228 1358 1031 1053 388 1624 1001 1509 192 858 1524 442 931 1210 1040 893 1420 1447 82 1382 1432 1059 1268 574