_From @Tusharbalar on August 24, 2017 13:43_
Ionic Info
tushar@localhost:~/.../Ionic3/CornerStone/cornerstone-parent$ ionic info
cli packages: (/home/tushar/workspace/Ionic3/CornerStone/cornerstone-parent/node_modules)
@ionic/cli-utils : 1.9.2
ionic (Ionic CLI) : 3.9.2
global packages:
Cordova CLI : 7.0.1
local packages:
@ionic/app-scripts : 2.0.2
Cordova Platforms : android 6.2.3 browser 4.1.0
Ionic Framework : ionic-angular 3.5.3
System:
Android SDK Tools : 26.0.2
Node : v6.11.2
npm : 3.10.10
OS : Linux 4.11
I used Document Viewer plugin in my app.
it gives error: Error in SitewaertsDocumentViewer.viewDocument(): Missing Command Error
Test with this command: ionic serve and ionic cordova run browser

_Copied from original issue: ionic-team/ionic#12744_
_From @AmitMY on August 24, 2017 14:18_
Please move this issue to ionic-native. This repo is about the framework itself
Hello! Thank you for opening an issue with us!
I have moved this issue to ionic-team/ionic-native. Please track the issue over there.
Thank you for using Ionic
Any updates from your team ???
Yes, I have same problem like that sir....
+1 I have the same problem. This plugin not work.
Same here
+1 I have the same problem
An alternative to this plugin is:
With cors-anywhere you can get any PDF link, and with ng2-pdf-viewer you can view PDF.
+1 same error
you can call as follows
const options: DocumentViewerOptions = {
title: 'My PDF'
}
this.document.viewDocument('www/assets/help_guide.pdf', 'application/pdf', options)
+1 Same issue. Please anyone let me know, if any work around to make it work??
+1 Same issue here , specifically on iOS.
ERROR: Error in SitewaertsDocumentViewer.viewDocument():
Any progress on a fix....
+1 Same here
I have the solution for it.
just add file pulgin in ur project and see the below example:
this.document.viewDocument(this.file.applicationDirectory + 'www/assets/help_guide.pdf', 'application/pdf', options)
Path is relative to platform. Working code on iOS and Android should be something like:
if (this.platform.is('ios')) {
path = this.file.documentsDirectory;
} else if (this.platform.is('android')) {
path = this.file.dataDirectory;
}
this.document.viewDocument(path + 'www/assets/myFile.pdf', 'application/pdf', options);
Hi everyone,
i am also facing this error and able solve it.
in my case i am getting a url which contains pdf file.
downloadAndOpenPdf(url) {
let path = null;
if (this.platform.is('ios')) {
path = this.file.documentsDirectory;
} else if (this.platform.is('android')) {
path = this.file.dataDirectory;
}
const transfer = this.transfer.create();
transfer.download(url, path + 'myfile.pdf').then(entry => {
let url = entry.toURL();
this.document.viewDocument(url, 'application/pdf', {});
});
}
here file is
import { File } from '@ionic-native/file';
and transfer is
import { FileTransfer } from '@ionic-native/file-transfer';
it only worked in real device. not worked in "ionic cordova run browser".
hope it will help someone.
Most helpful comment
Hi everyone,
i am also facing this error and able solve it.
in my case i am getting a url which contains pdf file.
downloadAndOpenPdf(url) {
let path = null;
if (this.platform.is('ios')) {
path = this.file.documentsDirectory;
} else if (this.platform.is('android')) {
path = this.file.dataDirectory;
}
const transfer = this.transfer.create();
transfer.download(url, path + 'myfile.pdf').then(entry => {
let url = entry.toURL();
this.document.viewDocument(url, 'application/pdf', {});
});
}
here file is
import { File } from '@ionic-native/file';
and transfer is
import { FileTransfer } from '@ionic-native/file-transfer';
it only worked in real device. not worked in "ionic cordova run browser".
hope it will help someone.