Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

salioudiabate's avatar

DOMPDF add a header and footer

How can I add a header and footer in my page with barryvdh/laravel-dompdf

0 likes
5 replies
stathisg's avatar

I assume you figured how to do that by now, but in case it helps someone in the future:

The following will add a header and a footer with the page number at the centre of it.

CSS:

.header,
.footer {
    width: 100%;
    text-align: center;
    position: fixed;
}
.header {
    top: 0px;
}
.footer {
    bottom: 0px;
}
.pagenum:before {
    content: counter(page);
}

HTML (add it at the beginning of your body tag):

<div class="header">
    Page <span class="pagenum"></span>
</div>
<div class="footer">
    Page <span class="pagenum"></span>
</div>
9 likes
cristian_h033's avatar

Hi, My header is variable, so I try to make a 'height auto' header that push the page content. ¿is it possible?

Sorry for my english.

1 like
mantella's avatar

HI,

Do you know if there is an option to disable the footer on the last page? I have been trying a lot, but cant get it working.

Thank you.

Please or to participate in this conversation.