How to set a bottom margin in FPDF
Solution 1
I just found the solution - the bottom margin is simply left out of predefinition because it is part of the page break calculation process. Therefore, setting a bottom margin in itself is not possible, but it can be done using
SetAutoPageBreak(boolean auto, [float margin])
Solution 2
+1 to SquareCat's answer. To expand on this a little more, if you're having trouble with text going a little bit over the auto page break, just setting SetAutoPageBreak(false) will probably be sufficient to solve the problem. For me personally this was causing trouble when creating mailing labels.
$fpdf->SetAutoPageBreak(false);
Just make sure that you're manually breaking pages where appropriate for your PDF.
$fpdf->AddPage();
Related videos on Youtube
SquareCat
squarec🐱t loves starburst. squarec🐱t fathers no children. squarec🐱t doesn't like people with a low z-index. /***** * Here we will refrain from obsessive dynamicism and leap into the darkness of hardcoded pain. *****/
Updated on July 09, 2022Comments
-
SquareCat over 1 year
I've taken a dive into FPDF lately and something that i don't seem to understand is - why is there no way to set a bottom margin? There are functions for setting margins from the top, left and right, but not from the bottom.
I assume now that i misunderstand something basic and conceptual about how FPDF works yet i got no clue on what that could possibly be.
So to cut it down:
Is it possible to define a fixed bottom margin in FPDF?
-
gonatee almost 7 yearswe can also use some $counter to detect the content area like > if($counter + $nextLineHeight > $contentAreaHeight) { $fpdf->AddPage(); }
-
G M over 1 year+1 To this post. I was using
$fpdf->SetAutoPageBreak(true)
along with manually breaking pages$fpdf->AddPage();
, which was causing page-break issues for me. Setting$fpdf->SetAutoPageBreak(false)
fixed my issue. Thank you @LAROmega