Version 0.8.0 How to add header and footer on every page except first?

90 views
Skip to first unread message

Mk Cheng

unread,
Nov 1, 2018, 1:05:22 PM11/1/18
to dompdf


DOMPDF Version 0.8.0 How to add header and  footer  with PAGE_NUM of PAGE_COUNT on every page except first? 

Mahadeva Reddy

unread,
Nov 2, 2018, 1:08:56 AM11/2/18
to dompdf
Hi Follow this structure page numbers works in Firefox only.
<table class="Report_Container_Mh" cellpadding="2" cellspacing="0" width="790" align="center">
<!-- Header Starts Here--> 
<thead class="Report_Header_Mh">
<tr>
<th>
<table width="100%" border="0" >
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</th>
</tr>
</thead>
<!-- Header Ends here--> 

<!-- Main Content Starts Here-->
<tbody class="Report_Content_Mh">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tbody>
<tr>
  <td>&nbsp;</td>
</tr>
  </tbody>
</table>


</td>
</tr>
</tbody>
<!-- Main Content Ends here--> 

<!-- Footer Starts here-->
<tfoot class="report_footer_Mh">
<tr>
<td class="report_footer_cell_Mh">&nbsp;</td>
</tr>
<tr><td>&nbsp;</td></tr>
<tr>
<td>
<div class="footer_info_Mh">
<div class="report_footer_counter_Mh" style="text-align: right;padding: 5px 10px;"></div>
</div>
</td>
</tr>
  </tfoot>
<!-- Footer Ends here-->
</table>

<style>

thead.Report_Header_Mh {
display: none;
}
tfoot.Report_Footer_Mh {
display: table-footer-group;
}
table.print > tbody > tr {
page-break-inside: avoid;
}
tabel.Report_Container_Mh {
page-break-after: always;
overflow: clip
}

@media print {
@-moz-document url-prefix() {
body { counter-reset: page; } 
.report_footer_counter_Mh:after{
counter-increment: Page;
content: "Page " counter(Page);
text-align: center;
z-index: 20px;
}
}
.report_footer_counter_Mh { 
display: block; 
}
}
</style>

BrianS

unread,
Dec 28, 2018, 9:46:54 PM12/28/18
to dompdf
With current releases of dompdf (as of this post up to 0.8.3) if you know where page one ends you can just define the header/footer at that point. These releases of dompdf start rendering fixed-position elements starting with the page on which it is encountered.

If you do not know this it's a bit more difficult but still possible. If you need it let me know and I'll try to dig up an example I created showing how you might accomplish this feat. It's a bit kludgey but I believe it works.
Reply all
Reply to author
Forward
0 new messages