DocumentViewer is not working for me


#1

Hi,

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??

ioni_info


#2

Did you remote debug the problem on the device already? Follow these instructions here to debug the problem in Chrome dev tools: https://ionic.zone/debug/remote-debug-your-app#android Look at the console and network tabs for errors.

Does the file exist?
Is the path correct?
Tried https://ionicframework.com/docs/native/document-viewer/#canViewDocument?


#3

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


#4

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


#5

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!


#6

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(CordovaResourceApi.java:452)↵	at org.apache.cordova.CordovaResourceApi.getUriType(CordovaResourceApi.java:105)↵	at org.apache.cordova.CordovaResourceApi.mapUriToFile(CordovaResourceApi.java:150)↵	at de.sitewaerts.cordova.documentviewer.DocumentViewerPlugin.getFileNew(DocumentViewerPlugin.java:850)↵	at de.sitewaerts.cordova.documentviewer.DocumentViewerPlugin.getFile(DocumentViewerPlugin.java:841)↵	at de.sitewaerts.cordova.documentviewer.DocumentViewerPlugin.canGetFile(DocumentViewerPlugin.java:678)↵	at de.sitewaerts.cordova.documentviewer.DocumentViewerPlugin.doExecute(DocumentViewerPlugin.java:351)↵	at de.sitewaerts.cordova.documentviewer.DocumentViewerPlugin.access$000(DocumentViewerPlugin.java:49)↵	at de.sitewaerts.cordova.documentviewer.DocumentViewerPlugin$1.run(DocumentViewerPlugin.java:184)↵	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)↵	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)↵	at java.lang.Thread.run(Thread.java:762)↵" message : "Relative URIs are not supported."