Javascript打印表与分页符

时间:2013-10-22 10:28:57

标签: javascript php jquery css printing

我正在尝试使用JQuery函数将使用PHP创建的表打印到打印机,但是虽然我尝试插入分页符,但表格并不是平滑地打印在每页上。

这是我使用的功能:

function PrintNeedsSS() {
    var docprint = window.open("", "_blank"); 
    var oTable = document.getElementById("show_needs_table");
    docprint.document.open(); 
    docprint.document.write('<html><style type="text/css" media= "print">      table {     page-break-inside:auto; position:relative} tr { page-break-before:avoid; page-break-after:auto;position:relative} td{ border:solid 1px #CCCCCC;width:auto;position:relative} thead { display:table-header-group;position:relative } tfoot { display:table-footer-group;positioion:relative} </style><head><title>NEEDS</title>'); 
docprint.document.write('<body><center>');
    docprint.document.write(oTable.parentNode.innerHTML);
    docprint.document.write('</center></body></html>'); 
    docprint.document.close(); 
    docprint.print();
    docprint.close();
}

有什么想法吗?

编辑:添加了我需要打印的表格

<table border="1" id="show_needs_table" style="width: 890px;border-collapse:   collapse;border-top: none;cursor: pointer;position: absolute;page-break-inside: avoid">
<tr></tr>
<tr></tr>   
</table>

0 个答案:

没有答案
相关问题