Home > PHP > Create PDF On The Fly Using PHP And FPDF

Create PDF On The Fly Using PHP And FPDF

January 12th, 2009 admin Leave a comment Go to comments
  1. June 11th, 2009 at 04:55 | #1

    Having spent the last 2 days looking for additional documentation, other than the fpdf.org site content. This is the best explained script I have seen to date. Great job.

    We have need to print multiple written direction pages we call MAPS. Some of the MAPS use 1 page while others use 2 pages. All the MAPS are output to the screen in one file and the operator after viewing can print them.

    Problem is we want to display a JPG on the last page of each individual MAP, whether 1 or 2 pages long. Code below is what I have, but it does not disyplay the header or footer, thus I am unable to put a JPG in the footer.

    Image(’images/cfv_logo_bw.gif’,5,8,30);
    //Arial bold 15
    $this->SetFont(’Arial’,'B’,20);
    //Move to the right
    $this->Cell(90);
    //Title
    $this->Cell(30,10,’Directions’,1,0,’C');
    //Line break
    $this->Ln(20);
    }

    //Page footer
    function Footer()
    {
    //Position at 1. cm from bottom
    $this->SetY(-10);
    //Arial italic 8
    $this->SetFont(’Arial’,'I’,8);
    //Page number
    $this->Cell(0,10,’Page ‘.$this->PageNo().’/{nb}’,0,0,’C');
    }
    }

    //Instanciation of inherited class
    $pdf=new FPDF(”P”, “mm”, “Letter”);
    $pdf->AliasNbPages();
    $pdf->SetFont(’Times’,”,12);
    $off = 4;
    $X[1] = 5;
    $X[2] = 130;
    $X[3] = 160;
    $Y[1] = 40;
    $Y[2] = 50;
    $Y[3] = 60;
    $page_count = 0;

    if(isset($fcabin_name))
    foreach ($fcabin_name as $i => $junk) {

    $pdf->AddPage();
    $pdf->Image(’../images/cfv-logo-pdf.jpg’,2,2,0);
    $pdf->SetFont(’Times’,'BIU’,18);
    $pdf->Text($X[1], $Y[1], $fcabin_name[$i]);
    $pdf->SetFont(’Times’,'BI’,16);
    $pdf->Text($X[2], $Y[1], “Door Code:”);
    $pdf->Text($X[3], $Y[1], $fkeycode[$i]);
    $pdf->SetFont(’Times’,'B’,14);
    $pdf->Text($X[1], $Y[2], “Directions:”);
    $pdf->SetFont(’Times’,'B’,12);
    $pdf->Text($X[1], $Y[3], “From Cabin Fever Vacations Office:”);
    $pdf->SetY(65);
    $pdf->SetFont(’Times’,”,12);
    $pdf->MultiCell(0, 6, $fdirections[$i],0,’L');
    // $pdf->Image(’../images/thai-pdf-coupon.jpg’,20,0,0);
    $page_count++;

    }
    $pdf->Output();
    ?>

  1. No trackbacks yet.