Skip to content

Instantly share code, notes, and snippets.

@mping
Created October 14, 2010 14:37
Show Gist options
  • Save mping/626264 to your computer and use it in GitHub Desktop.
Save mping/626264 to your computer and use it in GitHub Desktop.
xhtmlrenderer (Flying Saucer) with css3 header/footer
<link href="print.css" rel="stylesheet" type="text/css" media="screen,print"/>
...
<div style="-fs-page-sequence: start; page-break-before: always">
<div style="position: running(current);">
<div id="page-header" class="small">
<span class="align-left">some stuff here</span>
<span class="align-right">some other stuff here</span>
<div class="line">&#160;</div>
</div>
</div>
<div style="position: running(footer);">
<div id="page-footer" class="small">
<div class="line">&#160;</div>
Page <span class="page" /> of <span class="pagecount" />
</div>
</div>
content here
</div>
.small {font-size: xx-small;}
.line{border-bottom: 1px solid black}
/**
* Specific Elements
*/
#page-header {
display: inline;
}
#page-footer{
text-align: right;
}
/**
* Flying Saucer custom stuff
*
* see https://xhtmlrenderer.dev.java.net/servlets/ReadMsg?listName=dev&msgNo=3707
*/
@page {
size: letter; /*letter landscape*/
background: white;
@top-center {
content: element(current);
}
@bottom-right {
content: element(footer);
}
}
.page-start { -fs-page-sequence: start; page-break-before: always;}
table {-fs-table-paginate: paginate;page-break-inside: avoid;}
/* forces a page break */
.break {page-break-after:always}
span.page:before { content: counter(page); }
span.pagecount:before { content: counter(pages); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment