0👍
I just changed the way with an iframe
let myWindow = window.frames["printf"];
let printScript = '<script>if(typeof printCopies === "undefined"){ let printCopies = 0;} printCopies = '+ app.printCopies + '; function printDocument(){if(printCopies > 0){ for(let i= printCopies ; i>= 0; i--){ window.print(); } } else{ window.print();}} </script>';
myWindow.document.write( printScript + '<body onload="printDocument()">'+receiptHtml '</body>' );
Source:stackexchange.com