我使用 ITextRenderer 从 CSS 和 HTML 生成 PDF。但我不知道如何在 9 之间增加距离。一些文本和@top-center 的 border-bottom。
这是我的样式:
@page {
counter-increment: page;
margin-top: 80px;
@top-center {
font-size: 9pt;
content: "Page Header";
border-bottom: 2px solid black;
white-space: pre;
margin-bottom: 40px;
}
}
现在是这样的: a http://oi58.tinypic.com/fmto5d.jpg
这就是我要找的结果。
最佳答案
您需要在@page 定义中增加margin-top。边距框受@page 定义赋予它们的空间量的限制。
编辑:如果设置@top-center 框的高度会怎样?
根据 the specification ,您的代码应该可以工作。 我在我的样式表中使用了类似的东西,当我用 Antennahouse 渲染它时它起作用了:
@page portrait {
size: Letter;
margin-top: 28mm;
margin-bottom: 28mm;
margin-left: 25.4mm;
margin-right: 25.4mm;
@top-left {
font-size: 9pt;
font-family: Arial, sans-serif;
border-bottom: 0.5pt solid black;
margin-bottom: 10mm;
vertical-align: bottom;
padding-bottom: 1mm;
content: "Header";
}
}
关于html - 从 CSS 和 HTML 生成 PDF,@page @top-center 和内容之间的距离更大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29237096/