Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a bottom margin in FPDF

Tags:

php

margin

pdf

fpdf

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?

like image 509
SquareCat Avatar asked Sep 24 '12 14:09

SquareCat


People also ask

How do you set the bottom margin in Fpdf?

$fpdf->SetAutoPageBreak(false); Just make sure that you're manually breaking pages where appropriate for your PDF.

How do I set page breaks in Fpdf?

php require('fpdf. php'); $pdf = new FPDF('P','mm','A5'); $pdf->AddPage('P'); $pdf->SetDisplayMode(real,'default'); $pdf->SetFont('Arial','',10); $txt = file_get_contents('comments. txt', true); $pdf->Write(8, $txt); $pdf->Output(); ?>


1 Answers

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]) 
like image 188
SquareCat Avatar answered Sep 18 '22 15:09

SquareCat