html - @page bottom-centre CSS property doesn't repeat for each page when used with running element
问题描述
I'm trying to create a footer for my PDF file generated with HTML. I'm able to create a header that repeats for each page. Strangely enough, when I use the exact same technique to implement the footer, only the last page of the PDF has the footer. I'm doing it like this
@page{
size: a4 landscape;
@top-center {
content: element(header);
}
@bottom-center {
content: element(footer);
}
margin-top: 12em;
margin-bottom: 12em;
margin-left: 1em;
margin-right: 1em;
}
footer {
position: running(footer);
text-align: center;
padding: 5px 5px;
}
header{
position: running(header);
}
<footer>
Some text
</footer>
Is this a problem with CSS itself or the HTMLToPDF library I am using? I'm using openHTMLtoPDF Java library. Or is this a problem with me?
解决方案
Making the running element the first element after the body tag solved the problem for me.
推荐阅读
- python - 在 PyTorch 的分布式训练中如何设置随机种子?
- python - Python中的字符串到日期转换
- windows - xampp控制新安装
- c++17 - 通用插入排序算法不移动列表中的第一个对象
- visual-studio - Visual Studio 2019 进入智能感知创建换行符
- javascript - 如何仅获取 URL 参数名称而不是值
- django - 我应该使用 django.contrib.auth.models 用户模型吗?还是创建自己的用户模型更好?
- c# - C# 中 Ping 的实际/硬超时
- java - JScrollPane 组件不出现
- javascript - 有人知道如何在数组中添加额外的逗号和字符串吗?