yoL*_*tus 5 css python pdf formatting weasyprint
由于WeasyPrint,我用Django生成了一个用pdf渲染的表格.
这个表可能很长(说行数),所以可能会在几页pdf结果中结束.我必须在页面的每一端都包含一个静态页脚,所以我应用了css 固定规则.
我的问题是这个页脚与很长的表重叠.我如何要求WeasyPrint(通过我认为css)在每个页脚之前打破表并继续在下一页上呈现表格?
<table>
<tr></tr> <!-- a lot of rows, potentially spreading on several A4 pages -->
</table>
<footer style="position: fixed"> <!-- footer contents will be repeated and overlapped on each page until </table> is not reached -->
</footer>
Run Code Online (Sandbox Code Playgroud)
我尝试使用css规则作为padding-bottom应用于表标记但没有成功
谢谢
我找到了解决方案.
首先,您要定义页边距:
@page {
size: A4;
margin: 15mm 20mm;
}
Run Code Online (Sandbox Code Playgroud)
我的顶部和底部边距为15毫米.
当您现在在页面/正文中放置固定页脚时,它将在"内部"这些边距内,而非fixed元素将与其重叠.所以你想要做的是将固定页脚移动到这些边距的"外部":
footer
{
position : fixed;
right : 0;
bottom : 0;
margin-bottom : -10mm;
height : 10mm;
text-align : right;
font-size : 10px;
}
Run Code Online (Sandbox Code Playgroud)
在fixed和bottom属性将放置在底部的每一页上的页脚,但利润率定义(在那里重叠)内.所述height指定页脚的高度,这是然后移动"外"的由负边缘margin-bottom属性.只需确保margin-bottom> = height.
干杯Domi
| 归档时间: |
|
| 查看次数: |
1934 次 |
| 最近记录: |