A PhoneGap plugin to handle documents (e.g. PDFs) loaded from a URL.
The plugin exposes one method on the window object:
handleDocumentWithURL(successHandler, failureHandler, url)
The parameters:
The plugin downloads a document and starts an intent, so that other installed applications can open it.
There is a special failure condition on Android, if the system doesn't have any application that can handle the given MIME type. In this case failureHandler
will be called with the error code 53
.
The plugin downloads the document and provides a preview of the document using the Quick Look framework, including the corresponding actions such as copy, print, etc.
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'
);