Search code examples
htmlcordovaoffline-caching

What is the best way to view attachments (PPT, PDF, DOC) in a Phonegap application?


I have been unable to find decent examples of Phonegap wrapped mobile applications that contain links to common file attachments and show how they are handled. For instance, on an iPad app, the viewer is able to accomodate PDFs and PPTs however the user is kicked out of their app experience (no back button).

How have you been handling such challenges?


Solution

  • I've written a simple plugin which opens all popular files using external applications installed on your device from Phonegap application.

    Plugin is available at: https://github.com/markeeftb/FileOpener

    However, before you open the file, you need to download it to the device using Cordova FileTransfer method, which isn't very hard to implement http://docs.phonegap.com/en/1.8.0/cordova_file_file.md.html

    Regarding the experience - when you open the external app to view the file and exit it, you return to Phonegap application, which is great!