Phonegap how to download and open pdf file in android app

前端 未结 4 1556
囚心锁ツ
囚心锁ツ 2020-12-06 12:54

recently i am working on a android apps build in phonegap, i am quite new with mobile development and this i smy first appsbut, and i am stuck when try to download some docu

4条回答
  •  悲哀的现实
    2020-12-06 13:37

    Try this to open any kind of documents from URL using following steps:

    • install this plugin : cordova plugin add https://github.com/ti8m/DocumentHandler
    • use this code :

      handleDocumentWithURL(function() { console.log('success'); }, function(error) { console.log('failure'); if (error == 53) { console.log('No app that handles this file type.'); } }, 'http://www.example.com/path/to/document.pdf');

    It works for me both on Android and IOS. I used it for open images and PDF files.

    Android : It opens files using system apps if available, otherwise it give an error, which you can handle.

    IOS : It opens files in popup like view with Done button and Option button.

    It doesn't show your docs URL.

    Source is available here : https://github.com/ti8m/DocumentHandler

提交回复
热议问题