I want to print a specific dive content using LWC. I have tried this using javascript:
let divContents = this.template.querySelector('.voucherContainer').innerHTML;
let a = window.open('', '', 'height=500, width=500');
a.document.write('<html>');
a.document.write(divContents);
a.document.write('</body></html>');
a.document.close();
a.print();
AND
printContents =this.template.querySelector('.voucherContainer').innerHTML;
originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
above codes are not working for LWC. What is the correct way to do this?