1

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)
}
supriya chauhan
  • 289
  • 1
  • 5
  • 19

2 Answers2

3

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.

Clijsters
  • 4,031
  • 1
  • 27
  • 37
Matthew M
  • 371
  • 4
  • 19
0

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)
}
rajesh
  • 1,475
  • 10
  • 23
  • error: Type '{ title: string; openWith(): void; }' is not assignable to type 'DocumentViewerOptions'. Types of property 'openWith' are incompatible. Type '() => void' is not assignable to type '{ enabled: boolean; }'. Property 'enabled' is missing in type '() => void'. – supriya chauhan Sep 12 '17 at 05:47