Try this way:
where var data= $("#divtoprint").html();
function ShowPrintWindowPopup(data) {
var mywindow = window.open();
mywindow.document.write('<html><head><title></title>');
mywindow.document.write('<style>');
mywindow.document.write('table, th, td { border-collapse: collapse;border: 1px solid black;width: 100%;text-align: left;border-spacing: 0;}');
mywindow.document.write('a {color: #428bca;text-decoration: none;} ,table > tbody > tr {height:auto!important},table > thead > tr > th, table > tbody > tr > th, table > tfoot > tr > th, table > thead > tr > td, table > tbody > tr > td, table > tfoot > tr > td{vertical-align:top;padding:2px;font-size:8px;}');
mywindow.document.write('table {border-collapse:collapse; table-layout:fixed;} , table td {border:solid 1px #fab; word-wrap:break-word; -ms-word-break: break-all; word-break: break-all; word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;-ms-hyphens: auto;hyphens: auto;}')
mywindow.document.write('</style>');
mywindow.document.write('</head><body style="direction:ltr;font-size:10px;">');
mywindow.document.write('<div style="text-align:center;font-size:16px;font-weight:bold;">title</div><br />');
mywindow.document.write('<br/><br/>');
mywindow.document.write(data);
mywindow.document.write('</body></html>');
mywindow.document.close();
mywindow.print();
return true;
}
[ask]をお読みください。 – CBroe