function openNewWindow(strPreviewId) {
let newWindowViewer = window.open("");
var index = mapPreviewIdWithFile[strPreviewId].indexOf('base64,');
var attachBody = mapPreviewIdWithFile[strPreviewId].substring(index + 7);
var attachmentMimeType = mapPreviewIdWithFile[strPreviewId].substring(0, index + 7);
newWindowViewer.document.write("<iframe width='100%' height='100%' src='" + attachmentMimeType + " " + encodeURI(attachBody) + "'></iframe>");
}
finally the iframe gets created like below:
<iframe width="100%" height="100%" src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAA9AAAALaCAYAAADZQrs6AAAAAXNSR0IArs4..."></iframe>
For files like more than 10MB the attachBody changes to 26 MB, thus it fails to render in the new window. Is there any other library or workaorund which handles large files.
UPDATE
I was trying with canvas, but with canvas the full inage is bnot being shown, only a part is being shown.
if (attachmentMimeType.indexOf('bmp') > -1 || attachmentMimeType.indexOf('gif') > -1 || attachmentMimeType.indexOf('jpeg') > -1 ||
attachmentMimeType.indexOf('jpg') > -1 || attachmentMimeType.indexOf('pdf') > -1 || attachmentMimeType.indexOf('png') > -1) {
newWindowViewer.document.write('<canvas id="c"></canvas>');
var canvas = newWindowViewer.document.getElementById("c");
var ctx = canvas.getContext("2d");
var image = new Image();
image.onload = function() {
ctx.drawImage(image, 0, 0, image.height, image.width);
};
image.src = attachmentMimeType + " " + encodeURI(attachBody);
} else {
newWindowViewer.document.write("<iframe width='100%' height='100%' src='" + attachmentMimeType + " " + encodeURI(attachBody) + "'></iframe>");
}