1
A
回答
3
不幸的是,CSS定义了page:first
伪元素,但没有定义page:last
。
您仍有可能利用飞碟的bug,这使得页脚仅在声明后才出现。因此,如果您将页脚div
置于HTML的末尾,它将只出现在最后一页上。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
.newpage{page-break-before:always}
@page{@bottom-center {content: element(footer)}}
#footer {position: running(footer);}
}
</style>
</head>
<body>
<div>Page 1 content</div>
<div class="newpage">Page 2 content</div>
<div class="newpage">Page 3 content</div>
<div id="footer">Footer on last page</div>
</body>
</html>
它也可以,如果你想在每一页上一个页脚,具有不同内容的最后一页。您只需在HTML中定义页脚div
两次。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
.newpage{page-break-before:always}
@page{
@bottom-center {content: element(footer)}}
#footer {position: running(footer);}
}
</style>
</head>
<body>
<div id="footer">Footer for all pages except last</div>
<div>Page 1 content</div>
<div class="newpage">Page 2 content</div>
<div class="newpage">Page 3 content</div>
<div id="footer">Footer on last page</div>
</body>
</html>
相关问题
- 1. 为什么页脚仅显示在最后一页上?
- 2. Apache-FOP XSL-FO如何仅在最后一页显示页脚
- 3. Word 2010仅在最后一页的页脚中显示表格
- 4. 如何将报告页脚仅显示在Reporting Services的最后一页上?
- 5. 只在最后一页上显示页脚
- 6. Postscript仅在最后一页添加页脚
- 7. JasperReports页脚仅打印在最后一页
- 8. 如何在最后一页上打印页脚仅
- 9. 在使用cfdocument时仅将页脚添加到最后一页
- 10. 在页眉后面显示页脚
- 11. iReports 4.5.1子报告仅显示在页脚中没有页码的最后一页
- 12. wicked_pdf:只能在最后一页显示页眉和页脚才可以显示页眉?
- 13. 最后一页不在scrapy中显示
- 14. 如何在第一页显示页脚?
- 15. 如何在报告的最后一页显示活动报告的页脚?
- 16. 页脚仅重叠一页
- 17. 我怎样才能有一个10cm页脚仅在最后一页
- 18. Crystal Report Show仅在最后一页上
- 19. 最后一页的XSL-FO页脚
- 20. LibreOffice:最后一页的页脚文本
- 21. Indesign:显示页脚中第一个和最后一个页码的编号
- 22. Crystal Report - 显示最后一页
- 23. PDF查看器显示最后一页
- 24. Codeigniter分页显示我在最后一页
- 25. 仅在第一页上显示记录
- 26. 页脚在最后打印页MPDF
- 27. 事件仅在第一次加载时显示,而不是在点击下一页或上一页后显示
- 28. 仅当使用jquery或javascript有多个页码时才显示第一页和最后一页?
- 29. ZF2分页程序不显示最后一页
- 30. 笨分页:(。),显示DOTS最后一页按钮
iText的2.1.7是我曾经写过的API,并[不应再被使用(https://developers.itextpdf.com/question/versions-older-than-5)。其中一个原因是你不再使用它的原因之一是它的年龄。 iText 2.1.7的日期从2009年开始。您还在使用飞碟。这是一个旧的第三方库,在旧的iText版本上编写。你应该考虑使用[iText 7 + pdfHTML](https://developers.itextpdf.com/content/itext-7-converting-html-pdf-pdfhtml)。浏览本教程,您会注意到[pdfHTML](https://itextpdf.com/itext7/pdfHTML)中有更多对CSS的支持。 –
至于你的问题,你可以使用'IEventHandler'创建一个显示自定义行为的页脚,如果你决定做正确的事情并升级到iText 7。[教程](https://developers.itextpdf.com/content/itext-7-converting-html-pdf-pdfhtml/chapter-4-creating-reports-using-pdfhtml)有一个自定义页眉或页脚可以如何创建的例子。您可能还想阅读[此评论](https://stackoverflow.com/questions/46238645/utf-8-encoding-characters-not-working-with-spring-mvc-lowagie-itext#comment79441200_46238645) –