I am getting blob data from API in below format.
const data = 'JVBERi0xLjcNJeLjz9MKMzQgMCBvYmoNCjw8DQovVHlwZSAvQ2F0YWxvZw0KL1BhZ2VzIDcgMCBSDQovTWV0YWRhdGEgMjYgMCBSDQo+Pg0KZW5kb2JqDQozNSAwIG9iag0KPDwgL1R5cGUgL09ialN0bSAvTGVuZ3RoIDQxMCAvRmlyc3QgMTQ1IC9OIDIxIC9GaWx0ZXIgL0ZsYXRlRGVjb2RlID4+DQpzdHJlYW0NCnicxdTBqhoxFAbgvTDv8L/A7ck5SSYT..............';
I have used below code to render PDF in IE, Chrome and Firefox.
openPDF(pdfData: string){
const byteArray = new Uint8Array(atob(pdfData).split('').map(char => char.charCodeAt(0)));
const url = window.URL.createObjectURL(new Blob([byteArray], {type: 'application/pdf'}));
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
window.open(url);
}else{
window.open(url);
}
}
above code working fine and opening PDF in Chrome and Firefox, but same code not working in IE 11, and display Access is denied. error in console.
I tried below code, but giving error as attached,
let newBlob = new Blob([pdfData], {type: "application/pdf"});
window.navigator.msSaveOrOpenBlob(newBlob);
I tried with iFrame as well, and it was opening blank PDF.
I have tried below code as well, which is downloading PDF in local system, but while opening file it display same error as above.
let newBlob = new Blob([pdfData], {type: "application/pdf"});
window.navigator.msSaveBlob(newBlob, 'one.pdf');