How do I open PDF document in new browser window?
The window should be full and withouth menu.
Just a PDF document in a clean full window with native Javasc
To do it from a Base64 encoding you can use the following function:
function base64ToArrayBuffer(data) {
const bString = window.atob(data);
const bLength = bString.length;
const bytes = new Uint8Array(bLength);
for (let i = 0; i < bLength; i++) {
bytes[i] = bString.charCodeAt(i);
}
return bytes;
}
function base64toPDF(base64EncodedData, fileName = 'file') {
const bufferArray = base64ToArrayBuffer(base64EncodedData);
const blobStore = new Blob([bufferArray], { type: 'application/pdf' });
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(blobStore);
return;
}
const data = window.URL.createObjectURL(blobStore);
const link = document.createElement('a');
document.body.appendChild(link);
link.href = data;
link.download = `${fileName}.pdf`;
link.click();
window.URL.revokeObjectURL(data);
link.remove();
}