I am displaying an HTML retrieved from the backend.
printHtml(htmlContent) {
var windowToPrint = window.open('', '_blank');
windowToPrint.document.write(htmlContent);
setTimeout(function () {
windowToPrint.document.close(); // necessary for IE >= 10
windowToPrint.focus(); // necessary for IE >= 10*/
windowToPrint.print();
windowToPrint.close();
}, 1000);
}
This method works smoothly on all browsers, but I am facing a challenge with popup blockers. Unfortunately, I cannot use printWindow.location because the HTML content is stored in a variable.