Prince PDF 页脚不显示
我正在使用 Prince 生成 PDF。我使用下面的样式表(更大的 css 文件的一部分)在包含页码的每个页面上包含页脚,但页脚没有出现。
所以问题是,我做错了什么?
@page {
size: A4;
margin: 24mm 22mm;
padding: 0;
@bottom-left
{
content: "Page " counter(page) " of " counter(pages);
font-size: 7pt;
font-family: Arial, Helvetica, sans-serif;
text-align: left;
white-space:nowrap;
color:Red;
}
}
I'm generating a PDF using Prince. I'm using the below stylesheet (part of a much larger css file) to include a footer on each page containing page numbers, but the footer doesn't appear.
So the question is, what am I doing wrong?
@page {
size: A4;
margin: 24mm 22mm;
padding: 0;
@bottom-left
{
content: "Page " counter(page) " of " counter(pages);
font-size: 7pt;
font-family: Arial, Helvetica, sans-serif;
text-align: left;
white-space:nowrap;
color:Red;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个影响以 UTF-8 字节顺序标记开头的 CSS 样式表的错误已在 Prince 7.1 中得到修复。
This bug affecting CSS style sheets beginning with the UTF-8 byte order mark has been fixed in Prince 7.1.
我发现了问题。我使用的 CSS 文件最初是在 VS.Net 2008 中创建的,但最近在 VS.Net 2010 中进行了编辑,将编码更改为带签名的 UTF-8。一旦我将编码(使用 VS.Net 中的“文件”->“高级保存选项”)更改为 UTF-8(不带签名),页脚就会在生成的 PDF 中正确显示。
显然,Prince 无法处理具有意外编码的文件中的所有 CSS(或者可能无法处理 UTF 签名?)。长话短说——如果一切看起来都很干净,而你快要失去理智了,请检查文件编码。
I discovered the problem. The CSS file I'm using was originally created in VS.Net 2008, but was recently edited in VS.Net 2010, which changed the encoding to UTF-8 with signature. Once I changed the encoding (using File-> Advanced Save Options in VS.Net) to UTF-8 WITHOUT signature the footer appeared correctly in the generated PDF.
Apparently Prince can't handle all of the CSS in a file with an unexpected encoding (or maybe it can't handle a UTF signature?). Long story short - if everything looks Kosher and you're about to lose your mind, check the file encoding.