Search code examples
phphtmlcssdompdf

Setting footer in dompdf


This is the required behavior(jsfiddle).

<!--Footer-->
<div id="footer">
<span class="alignleft">$unique_ID</span>
<span class="alignright"> Page <span class="pagenum"></span></span>
<div style="clear: both"></div>
</div>



.footer {
width: 100%;
position: fixed;
}
.footer {
bottom: 0px;
}

.pagenum:before {
content: counter(page);
}
.alignleft {
float: left;
}
.alignright {
float: right;
}

enter image description here But when using the exact same code in the html which the dobmpdf uses to render following is the result enter image description here

How to solve this problem. ($unique_ID is a php variable)


Solution

  • Dompdf up to and including version 0.6.2 does not have float support enabled by default. Modify your dompdf_config.custom.inc.php file such that the DOMPDF_ENABLE_CSS_FLOAT configuration constant is set to true.

    Dompdf up to and including version 0.7.0 does not support auto-calculated width. So even enabling float will not be enough for these versions. You will need to add a width to your floated elements for them to display correctly.

    Dompdf 0.7.1 and later should render this as expected.