I'm creating ionic 4 angular app ,and using file ,file opener ,file transfer , document viewer to open pdf in mobile devices . Now i want to open pdf in web browser ? Below my code for open pdf ...
// My method for open pdf
openLocalPdf() {
let filePath = this.file.applicationDirectory + 'www/assets';
if (this.platform.is('android')) {
let fakeName = Date.now();
this.file.copyFile(filePath, '5-tools.pdf', this.file.dataDirectory, `${fakeName}.pdf`).then(result => {
this.fileOpener.open(result.nativeURL, 'application/pdf')
.then(() => console.log('File is opened'))
.catch(e => console.log('Error opening file', e));
})
} else {
// Use Document viewer for iOS for a better UI
const options: DocumentViewerOptions = {
title: 'My PDF'
}
this.document.viewDocument(`${filePath}/5-tools.pdf`,
'application/pdf', options);
}
}