I’ve created a page that in a button click downloads a specific pdf file from the database. It works fine in the browser but in an actual mobile, it doesn’t download the file.
Thanks in advance!
My code:
getPdfFile(item){
let array = new Uint8Array(item);
let blob = new Blob([array], { type: 'application/pdf' });
let url = URL.createObjectURL(blob);
this.modalName = array;
let fileName: string = new Date().toLocaleDateString();
try {
const link = document.createElement('a');
if (link.download !== undefined) {
link.setAttribute('href', url);
link.setAttribute('download', fileName);
link.style.visibility = 'hidden';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
} catch (e) {
console.error('BlobToSaveAs error', e);
}
}
Is there a way I can show the pdf files without the need to download them?