-
Notifications
You must be signed in to change notification settings - Fork 68
Description
Hello
I tried to open a simple one page PDF file from:
- external url (e.g basic http://www...../test.pdf)
- local file using relative path (e.g ./test.pdf)
- local file using absolute pah (e.g file:///android_asset/www/test.pdf)
Below is the result of tests using DocumentHandler@0.2.2 plugin on android (app built using cordova 7.1.0):
// Android 7 / 8: KO - app instantly crashes
// Android 6: OK
handleDocumentWithURL(function(){ console.info('success'); }, function(){ console.error(arguments); }, EXTERNAL_URL);
// Android 6 / 7 / 8: KO - 1 (undefined error)
handleDocumentWithURL(function(){ console.info('success'); }, function(){ console.error(arguments); }, LOCAL_RELATIVE_PATH);
// Android 6 / 7 / 8: KO - app instantly crashes
handleDocumentWithURL(function(){ console.info('success'); }, function(){ console.error(arguments); }, LOCAL_ABSOLUTE_PATH);
Note: We've used the exact same version of the plugin on an app during summer 2016 (1 year and a half ago) and it is working on Android 6 / 7 / 8, so I suppose this plugin just lacks maintenance to be compatible with recent Cordova versions?
Alternatives:
- I've tried Mozilla's PDF.js, which is not cordova related but a full javascript library to display PDF files, but I did not managed to come to anything satisfying (no UI, no interaction...), seems very limited.
- sitewaerts cordova-plugin-document-viewer requires you to install a third party PDF reader app (developed by sitewaerts)
- cordova-plugin-file-opener2 : got an error: File not found for each one of the 3 scenarios described above.
- vanilla JS, only works for external URLs (see https://www.raymondcamden.com/2016/06/26/linking-to-pdfs-in-cordova-apps/):
window.open(decodeURI(EXTERNAL_URL), '_system', 'location=no');