Print doesn't work in Chrome the first time
I have html content and image and print the page on button click. When I print it the first time, the print preview page is blank and the second time it is ok. Please help why it won't print the page the first time
The image source is in base-64 format. So, due to the large content, I cannot add the code snippet, please check with the demo link.
<input type="button" id="printImage" onclick=printImage() value="print" />
function printImage() {
var htmlContent = "The html code in stack-overflow exceeded. So please check with demo link for html content";
var win = window.open();
win.document.write(htmlContent);
win.document.close();
win.focus();
win.print();
win.close();
}
Someone help me with this.
+3
source to share
3 answers