ti8m / DocumentHandler

A phonegap plugin to handle documents (f.e. PDFs) loaded from a URL.
MIT License
30 stars 70 forks source link

DocumentHandler

A PhoneGap plugin to handle documents (e.g. PDFs) loaded from a URL.

Usage

The plugin exposes one method on the window object:

handleDocumentWithURL(successHandler, failureHandler, url)

The parameters:

Android

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.

iOS

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.

Example usage

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'
);