I need to apply Header & footer text in each page of PDF, for that i am using below line of CSS.By this I am able to apply Header text in each page but not footer text. I am getting footer text only in last page of PDF.
@@page {
@@top {
content: element(header);
}
@@bottom {
content: element(footer);
}
}
header {
padding: 10px;
position: running(header);
}
footer {
padding: 5px;
position: running(footer);
}
I am assuming you are using something like dompdf to generate your PDFs from HTML. If not, I apologise and found similar code to this elsewhere that produces headers and footers on all pages. This seems to work for printing normally from browser as well as to PDFs.
CSS
HTML code
The addition of the content class along with the height specified in the elements header and footer helps stop the content from just writing all over your header and footer on each page.