Whenever I use window.print in my JavaScript code to print a specific div, I encounter alignment issues on the printed page.
Below is the snippet of code that I am using for printing along with links to images showing the output and the layout after printing:
function PrintPopup() {
var data = $("#viewCoupon").html();
var mywindow = window.open('', 'Print Data', 'height=540,width=980');
mywindow.document.write("<html><head><title>Bonus Box Offer</title>");
mywindow.document.write("<link href=\"Content/style.css\" rel=\"stylesheet\" />");
mywindow.document.write("<style>.userwinners{margin-top: 51px;margin-left: 0;} .no-Print{display:none;} @media print {.no-Print{display:none;} title {display:none;} }</style>");
mywindow.document.write("</head><body >");
mywindow.document.write(data);
mywindow.document.write("</body></html>");
mywindow.document.close(); // necessary for IE >= 10
mywindow.focus(); // necessary for IE >= 10
mywindow.print();
//mywindow.close();
return true;
}