gpt4 book ai didi

python - WeasyPrint:修复了每个 pdf 页面上长表重叠的页脚标签

转载 作者:技术小花猫 更新时间:2023-10-29 11:30:29 29 4
gpt4 key购买 nike

我用 Django 生成了一个表格,感谢 WeasyPrint,我以 pdf 格式呈现。

此表可能非常长(行数),因此可能以几页 pdf 结果结尾。我必须在页面的每一端包含一个静态页脚,所以我应用了 css fixed 规则。

我的问题是这个页脚被很长的表格重叠了。我怎样才能要求 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>

我尝试将 css 规则用作应用于表格标签的 padding-bottom 但没有成功

谢谢

最佳答案

我找到了解决方案。

首先,您必须定义页边距:

@page {
size: A4;
margin: 15mm 20mm;
}

我的顶部和底部边距为 15 毫米。

当您现在在页面/正文中放置固定页脚时,它将位于这些边距“内部”,并且非固定 元素将与它重叠。因此,您要做的是将固定页脚移到这些边距的“外部”:

footer
{
position : fixed;
right : 0;
bottom : 0;
margin-bottom : -10mm;
height : 10mm;
text-align : right;
font-size : 10px;
}

fixedbottom 属性会将您的页脚放在底部的每个页面上,但在定义的边距(重叠的地方)内。 height 指定页脚高度,然后通过负 margin-bottom 属性将页脚“移到”页边距之外。只需确保 margin-bottom >= height

干杯多米

关于python - WeasyPrint:修复了每个 pdf 页面上长表重叠的页脚标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30304258/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com