繁体   English   中英

如何避免openhtmltopdf中新页面上的空页眉/页脚行?

[英]How to avoid empty header/footer rows on new page in openhtmltopdf?

我正在使用openhtmltopdf在 pdf 文档中生成分页表渲染,在模板下方渲染额外的 header 和页脚,这不应该是,因为没有更多的行了。

 <html>

<head>
    <style>
        @page {
            size: 400px 350px;
        }

        table {
            width: 100%;
            font-size: 16px;
            border-collapse: collapse;

            /* The magical table pagination property. */
            -fs-table-paginate: paginate;

            /* Recommended to avoid leaving thead on a page by itself. */
            -fs-page-break-min-height: 1.5cm;
        }

        tr,
        thead,
        tfoot {
            page-break-inside: avoid;
        }

        td,
        th {
            padding: 6px;
            border: 1px solid gray;
        }

        tfoot td {
            background-color: aqua;
        }

        thead th {
            background-color: coral;
        }
    </style>
</head>

<body>
    <table>
        <caption>
            <p>This example shows how to use table pagination.</p>
            <p>The table header and footer are automatically reproduced on each page.</p>
        </caption>

        <thead>
            <tr>
                <th>Title 1</th>
                <th>Title 2</th>
            </tr>
        </thead>

        <tbody>
            <tr>
                <td>Hello</td>
                <td>World!</td>
            </tr>
            <tr>
                <td>Hello</td>
                <td>World!</td>
            </tr>

        </tbody>

        <tfoot>
            <tr>
                <td>Footer 1</td>
                <td>Footer 2</td>
            </tr>
        </tfoot>
    </table>
</body>

</html>

这是 output 文档截图供参考。 新页面上带有空页眉页脚的表格

你能帮忙吗,如何消除那些行?

仅供参考,这是用于快速测试的沙盒链接: https://sandbox.openhtmltopdf.com/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM