/*
`domStr` here should contain everything including <html>, the styles, the title and all.
Use the printing dialogue from your browser to toggle the headers, the backgrounds.
*/
function putInIFrame() {
let domStr = "// HTML string here";
// your #iframe ; can be [hidden] to avoid it beeing shown on screen
const hideFrame = document.getElementById('iframe');
hideFrame.contentWindow.document.body.innerHTML = ""; // empty iframe in case it wasn’t empty
hideFrame.contentWindow.document.write(domStr); // write domStr to iFrame
hideFrame.contentWindow.print(); // print iframe
}