I have a button in my web-application (java, jsp, js) that allows printing by taking HTML from selected areas of the screen, and placing it in an iframe called 'iFramePrint' and then printing it.
<iframe name="iFramePrint" frameborder="0" src="Blank.jsp" marginheight="0" marginwidth="0" width="0" height="0"></iframe>
function doPrint() {
if (window.frames['iFramePrint'].document.body) {
var str = '<B>'+'<h1>' + document.getElementById('tdMainTitle').innerHTML +'</h1>'+'</B>';
str += '<BR>';
etc.
str=str.replace(/BORDER=0/g ,"border=1");
window.frames['iFramePrint'].document.body.innerHTML = str;
window.frames['iFramePrint'].focus();
window.frames['iFramePrint'].print();
}
}
This has worked well for a long time, however due to a recent Windows Update, the code no longer works. See below.
I preferably do not want to wait for Microsoft to fix this - it could be a while. And I do not want to ask clients to uninstall KB4022715 (the Knowledge Base number varies depending on the windows version, but generally speaking it's the security update rollup for Jul, released this month) which does fix the problem.
I have a solution how to solve this - to take the HTML and convert it to a PDF and then allow the user to download the PDF, which is definitely doable. See Converting HTML files to PDF - just wondering if there is a better way.