批量打印 | 多页打印 | PHP多页打印

一直以为很难,一定需要插件什么的。或者要精通JS

看到一篇文章发现就在div加上一行属性就行了...

发布记录一下,很久以前就想要实现的功能了。

上代码:

<script>
    window.print(); //默认自动弹出打印框
</script>
<DIV STYLE="page-break-before:always">
    <table width="300px" height="100px" border=1>
        <th>列1</th>
        <th>列2</th>
        <tr>
            <td>数据1</td>
            <td>数据2</td>
        </tr>
    </table>
    <br />
</DIV>
<!-- 下面是重复数据 -->
<DIV STYLE="page-break-before:always">
    <table width="300px" height="100px" border=1>
        <th>列1</th>
        <th>列2</th>
        <tr>
            <td>数据1</td>
            <td>数据2</td>
        </tr>
    </table>
    <br />
</DIV>

实际效果

原文地址:https://www.cnblogs.com/insane/p/14225447.html