I am trying to download the pdf from the server link to the local storage and then open the local pdf using the fileopener2. I am currently concerned with the android only.
But due to some reason, it is giving me the following error
Following the code of my various files
documents.page.ts
viewPDF(downloadURL) {
console.log("jello");
this.miscService.nowLoader();
let path = this.file.dataDirectory;
const transfer = this.filetransfer.create();
transfer.download(downloadURL, `${path}myfile.pdf`).then(entry => {
let url = entry.toURL();
console.log(this.platform.platforms);
if (this.platform.is('ios')) {
console.log("IN IOS");
this.documentviewer.viewDocument(url, 'application/pdf', {});
this.miscService.hideLoader();
} else {
console.log("IN Android");
console.log(url);
this.fileopener.open(url, 'application/pdf').then(()=>{
console.log("File opened");
},
err => {
console.log("Error "+err.message);
}
);
this.miscService.hideLoader();
}
});
}
I have tried reading all the stackoverflow articles and unable to get it done. Can anyone see something wrong with this code?