1
votes

Trying the below code to open an offline pdf in ionic 2 application but the code is opening a pdf file in cleverdox viewer instead of adobe reader, how could i set adobe reader by default here to make pdf functional. Thanks in Advance.

open()
  {
  const options: DocumentViewerOptions = {
  title: 'My PDF'
  }
  this.document.viewDocument('file:///android_asset/www/assets/test.pdf', 'application/pdf', options)
}
2
did you find an answer?gaurang

2 Answers

3
votes

No idea if you got this resolved but here's what fixed the issue for me:

Make sure you are using the latest version of the document Viewer plugin.

open() {
  const options: DocumentViewerOptions = {
    title: 'My PDF',
    openWith: { enabled: true }, //this will allow you to open the document with an external application
    // any more options
  };
  this.document.viewDocument('file:///android_asset/www/assets/test.pdf', 'application/pdf', options);
}

The problem with @rj7 's code is that he added a function into what should be a nested object. For more information on the options you can pull through into this function, see the following URL: https://github.com/sitewaerts/cordova-plugin-document-viewer

Hope that helps to anyone stuck in the future.

0
votes

Try openWith() like below,

open()
  {
  const options: DocumentViewerOptions = {
  title: 'My PDF',
  openWith() {
    enabled: true
   }
  }
  this.document.viewDocument('file:///android_asset/www/assets/test.pdf', 'application/pdf', options)
}