DocumentViewer is not working for me


This is my code:

showDocument() {
    var options: DocumentViewerOptions = {
      title: 'A book',
      documentView: { closeLabel: '' },
      navigationView: { closeLabel: '' },
      email: { enabled: true },
      print: { enabled: true },
      openWith: { enabled: true },
      bookmarks: { enabled: true },
      search: { enabled: false },
      autoClose: { onPause: false }
    this.docViewer.viewDocument('assets/arabic.pdf', 'application/pdf', options);

Fo course I did not forget to import :slight_smile:

import { DocumentViewer,DocumentViewerOptions } from ‘@ionic-native/document-viewer’;

And in the HTML:

I added a button to call the function.

But when I run it (emulation), the click does not make any action (the triggering works fine since I added an Alert and it showed up).

What am I missing??


Did you remote debug the problem on the device already? Follow these instructions here to debug the problem in Chrome dev tools: Look at the console and network tabs for errors.

Does the file exist?
Is the path correct?

Yes true, this is what I got when I have debugged:

Did you fix this? Getting this on Android also. The documentation is wrong

1 Like

It is the same bug. True, documentation is wrong and the plugin is not working but I think only with new android (mine is 7). I am wondering where is Ionic Team!

Any Solution? Still getting the same problem. Working fine on the iOS platform but in Android showing below error message

* "java.lang.IllegalArgumentException: Relative URIs are not supported.↵	at org.apache.cordova.CordovaResourceApi.assertNonRelative(↵	at org.apache.cordova.CordovaResourceApi.getUriType(↵	at org.apache.cordova.CordovaResourceApi.mapUriToFile(↵	at de.sitewaerts.cordova.documentviewer.DocumentViewerPlugin.getFileNew(↵	at de.sitewaerts.cordova.documentviewer.DocumentViewerPlugin.getFile(↵	at de.sitewaerts.cordova.documentviewer.DocumentViewerPlugin.canGetFile(↵	at de.sitewaerts.cordova.documentviewer.DocumentViewerPlugin.doExecute(↵	at de.sitewaerts.cordova.documentviewer.DocumentViewerPlugin.access$000(↵	at de.sitewaerts.cordova.documentviewer.DocumentViewerPlugin$↵	at java.util.concurrent.ThreadPoolExecutor.runWorker(↵	at java.util.concurrent.ThreadPoolExecutor$↵	at↵" message : "Relative URIs are not supported."