Explanation : Here as you can see in image there are two windows open in Microsoft Edge browser to print pdf file. But I want to close my external window after opening a print preview window. I have mention windows title in image.
My Try :
var mywindow = window.open('', 'mywindow', 'height=600,width=800');
var html = '<html><head><title></title><style type="text/css" media="print">@@page { size: auto; margin: 5mm 0mm 0mm 10mm; } </style>' +
'</head><body>' +
contents +
'</body></html>';
mywindow.document.write(html);
mywindow.document.close();
mywindow.focus();
mywindow.print();
mywindow.close();
I have also refer some link as below.
https://stackoverflow.com/a/6040795/2798643
https://stackoverflow.com/a/11782214/2798643
https://stackoverflow.com/a/9616706/2798643
and many more links. So if anyone have any idea about it than let us know.