I have a function to print my page as follows:
$("#btn_print").click(function () {
var divToPrint = document.getElementById('printdiv');
var newWin = window.open('', 'Print-Window');
newWin.document.open();
newWin.document.write('<html><body onload="window.print()" style="font-family:consolas;@page { size:8.5in 11in; margin: 3cm };" >' + divToPrint.innerHTML + '</body></html>');
newWin.document.close();
setTimeout(function () {
newWin.close();
}, 10);
});
I need 3cm margin space on all sides I mean Top,Right, Bottom and Left
.
What I doing is above as you can see:
@page {
size: 8.5in 11in;
margin: 3cm;
};
But it is not working.