I’m generating PDFs using mPDF library, and my header and footer vary in size depending on a couple of parameters.
A static solution would be to set the footer margin, which will solve the overlapping – but as the footer may vary in size this is not a solution I feel happy with. Is there a way to get the footer dimensions and apply the margin accordingly?
The problem lies in the documentation of mpdf. I think margin_footer and margin_header is the margin between the document body and these. Instead, margin_footer and margin_header is the document margins, as one would think margin_top and margin_bottom would be.
So, changing the bottom and top margin will decide where the document body starts. And changing the header/footer margin will decide the printing margins.
Hope it helps!
Updated answer
mPDF documentation is a bit off for the constructor call, I guess. The margin_top/bottom argument is actually the content margin, and does not apply for margin_header/footer arguments. (If I recall correctly). The margin_top/bottom is the absolute margin from the top of the document, and should include the height of the header/footer.
Here is the correct way of handling the margins: