我意识到之前已经问过这个问题(我查看了所有解决方案并尝试了所有这些)但我仍然在尝试生成一个带有页眉和页脚的pdf文档,并在每个页面上重复.
我正在使用flying saucerR8,iText2.0.8我已经尝试了许多不同的方法来使其工作,但到目前为止无济于事.我测试的一些方法是https://gist.github.com/626264,使用运行元素和边距框 http://pigeonholdings.com/projects/flyingsaucer/R8/doc/guide/users-guide-R8.html# xil_40(css3功能),飞碟r7指南,不适用于r8 http://today.java.net/pub/a/today/2007/06/26/generating-pdfs-with-flying-saucer -and-itext.html #page-specific-features,很多其他方法对我不起作用.
我的标题div包含2个带图像的div,我的页脚仅用于页面编号.html被放入一个StringBuffer被调用的buf中.
buf.append("<head>");
buf.append("<title>blabla</title> ");
buf.append("<style type='text/css' media='print'> ");
buf.append("@page { size:8.5in 11in; padding:1em; @bottom-left { content: element(footer); } } ");
buf.append("#footer { font-size: 90%; font-style: italic; position: running(footer); top: 0; left: 0; }");
buf.append("#pagenumber:before { content: counter(page); } ");
buf.append("#pagecount:before { content: counter(pages); } ");
buf.append("</style></head>");
buf.append("<body>");
buf.append("<div class='header' style='clear:both;'>");
buf.append("<div id='moneyLogo' style='float:left'>");
buf.append("<img src='logo.jpg' alt='Some alt text' />");
buf.append("</div>"); …Run Code Online (Sandbox Code Playgroud)