【发布时间】:2018-05-16 15:56:16
【问题描述】:
我在表格中有一个 thead 标签,当将页面打印为 PDF 时,thead 中的标题将在每一页上重复。表格有2个section,每个section都有自己的header,整个大表都有自己的header。
<table>
<thead>
<tr><th>Header 1</th><th>Header 2</th><th>Header 3</th></tr>@*main header should always repeat in each page on the print out.*@
</thead>
<tbody>
<tr>@*I need Headers for 1st section to repeat in print out when the lines in section 1 cross 2 pages, and the main header should always repeat in each page.*@
<td>Header 1 for 1st section</td>
<td>Header 2 for 1st section</td>
<td>Header 3 for 1st section</td>
</tr>
<tr><td>1st section line 1</td><td></td><td></td></tr>
<tr><td>1st section line 2</td><td></td><td></td></tr>
<tr><td>1st section line 3</td><td></td><td></td></tr>
<tr>@*I need Headers for 2nd section to repeat in print out when the lines in section 2 cross 2 pages, and the main header should always repeat in each page.*@
<td>Header A for 2nd section</td>
<td>Header B for 2nd section</td>
<td>Header C for 2nd section</td>
</tr>
<tr><td>2nd section line 1</td><td></td><td></td></tr>
<tr><td>2nd section line 2</td><td></td><td></td></tr>
<tr><td>2nd section line 3</td><td></td><td></td></tr>
</tbody>
</table>
当第 1 节中的行跨越 2 页时,我需要第 1 节的标题在打印输出中重复,当第 2 节中的行跨越 2 页时,第 2 节的标题在打印输出中重复,并且主标题应该总是在每一页重复。
我尝试了许多不同的方法来做到这一点,但都没有奏效。
任何想法,请帮助。谢谢。
【问题讨论】:
-
您是否尝试过将主标题放在表格/标题中,然后在该正文中放置一行,一个单元格。在该单元格内放置另外两个表格及其标题和内容。因此,打破表格将重复外部表格(主标题)和内部表格标题。这就是在大多数使用 XSL FO 的发布系统中完成的方式,只是不确定它在 HTML 中是否有效。
-
是的,我做到了。只有里面的广告重复了。主表中的 thead 没有重复。
-
太糟糕了。在许多情况下,尝试使用浏览器打印功能创建复杂的打印文档可能会失败,比如这个。浏览器尚未了解印刷出版的复杂性。
-
您尝试过哪些浏览器?他们以不同的方式重复标题。
-
Internet explorer 11. 用户主要使用Internet Explorer。
标签: html pdf html-table