我正在使用flying problem /itext来生成基于HTML的PDF文件,我遇到了向PDF文件添加页眉和页脚的问题。我最终做了一个带有页眉和页脚的HTML表格,类似于:
<table>
<thead>
<tr>
<th>
Header stuff
</th>
</tr>
</thead>
<tfoot>
<tr>
<th>
Footer stuff
</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>
Content
</td>
</tr>
</tbody>
</table>
与css规则"table { -fs-table- paginate : paginate;}“一起,页眉和页脚可以正确分页。但是,我不能让页脚停留在页面的底部:
如果表格的内容填满了页面,则将页脚推到底部:
有没有办法在tbody不满的情况下把页脚压到底部??
谢谢,Julián
发布于 2017-03-15 00:25:15
你应该使用CSS 3 Paged media来添加页眉和页脚。这将解决您的问题(在页面底部显示页脚),但也为您提供了许多很好的选项(页码,第一页的特定页眉...)
以下是基本模板:
<html>
<head>
<style>
#header { position: running(header); }
#footer { position: running(footer); }
@page {
@top-center { content: element(header); }
@bottom-center { content: element(footer); }
}
</style>
</head>
<body>
<div id='header'>Header stuff</div>
<div id='footer'>Footer stuff</div>
<table>
<tbody>
<tr>
<td>
Content
</td>
</tr>
</tbody>
</table>
</body>
</html>
https://stackoverflow.com/questions/42786825
复制相似问题