In the most recent dompdf release (domdpf beta 2), inline php was disabled for security reasons. This, in turn, caused the previous footer/header code:
<script type="text/php">
if ( isset($pdf) ) {
$font = Font_Metrics::get_font("helvetica", "bold");
$pdf->page_text(72, 18, "Header: {PAGE_NUM} of {PAGE_COUNT}", $font, 6, array(0,0,0));
}
</script>
To no longer work.
I’m now trying to re-create what this script did using CSS. So far, I’ve figured out how to get CSS to count the pages:
.pagenum:before { content: counter(page); }
The issue I’m having is sticking the footer to the bottom of the page. Most CSS tutorials on how to do this do not seem to be working. Here’s the css for my page:
html,body {
font-family:interstate;
height:100%;
width:100%;
overflow:auto;
margin-left: 40px;
margin-right: 40px;
margin-top: 20px;
margin-bottom:40px;
min-height: 100%;
}
P.breakhere {page-break-before: always}
table
{
border-collapse: collapse;
page-break-inside: avoid;
font-size:15px;
}
td
{
border: 1px solid #000
}
.noBorder {
border: 0
}
#header {background:#ffffff url('gradient.png') no-repeat center center;
height: 100px;
}
#text {
position:relative;
text-align:center;
padding:10px;
}
.pagenum:before { content: counter(page); }
My hope is someone can provide me the appropriate #footer bit, so my footer text will properly stick to the bottom of the page.
Thank you!!
Inline script is disabled by default, but if you feel you are not vulnerable to any security problems you can safely re-enable it by setting
DOMPDF_ENABLE_PHPtotrue.To create a header/footer using HTML+CSS you would use a fixed-position element.
CSS
HTML
The main drawback to the HTML+CSS method is that there is currently no way to get the total number of pages using this method.