FPDF/FPDI Margin Problem

I’m using FPDF/FPDI to import a pdf and add a header to the page. Everything is working perfectly except a margin is being placed at the bottom of the page that I can’t seem to get rid of. I think what happens is that fpdi imports the pdf page (which already has a footer margin at the bottom) and then fpdf adds an additional margin below the imported pdf page. The problem is that instead of having 11’’ tall pdfs they are 11.69’’ tall (to tall for printing). Can anyone think of any tricks to remove this margin? I’ve looked through the fpdf documentation and have tried a couple things but nothing seems to be working.

My Code:


$journal = "Title";
$volume = "1";
$cid = "111111";
$year = "2009";
$doi = "10.1234";
$issn = "1234-5678";

$line1 = $journal . ", " . $volume . ", " . $cid . " (" . $year . ")";
$line2 = "DOI: " . $doi;
$line3 = "Name";
$line4 = "ISSN: " . $issn;

$galleyFile = "test.pdf";

$pdf =& new FPDI();

$pagecount = $pdf->setSourceFile($galleyFile);

//I was trying to use this to reduce the margin but it doesn't seem to be doing
$pdf->SetAutoPageBreak(true, 0);


for ($n = 1; $n <= $pagecount; $n++) {

//Add the header
$pdf->SetFont('Arial', '', 8);
$pdf->SetXY(10, 10);
$pdf->MultiCell(0, '', $line1 , 0 , L , false);
$pdf->SetXY(10, 14);
$pdf->MultiCell(0, '', $line2 , 0 , L , false);
$pdf->SetXY(160, 10);
$pdf->MultiCell(0, '', $line3 , 0 , R , false);
$pdf->SetXY(160, 14);
$pdf->MultiCell(0, '', $line4 , 0 , R , false);

//Import 1 page and set as a template
$tplidx = $pdf->ImportPage($n);
$size = $pdf->useTemplate($tplidx);

//Repeat for all pages in the pdf.
    if ($n != $pagecount) {

$pdf->Output($galleyFile, 'F');

Have you tried creating a new class which extends the FPDF class and overwrite the Footer method?



class MyFPDF extends FPDF{
  function Footer() {

It appears that FPDF defaults to A4 paper size if you initialize it like this:

$pdf = new FPDF();

Instead initialize FPDF like this:

$pdf = new FPDF('P','mm','Letter');

The above example is for P - portrait, mm - millimeter, Letter - paper size.

For posterity, i just wanted to say that changing the default FPDF() params fixed everything. I’ve been struggling with this for days.

Thanks Robert!

Just another point: new pages are automatically created if body text reaches the trigger distance set in SetAutoPageBreak with a default of 2cm. Set SetAutoPageBreak(true, 0) to use the full page before a new one is created.