I am trying to create id cards from records in my database. where the photo of a person would be on the left side and items of information like would be printed by the side and beneath as in the screenshot below. Screenshot of pdf output showing pagination issue
Using fpdf cells I am able to create pdfs with pagination. But for the said purpose I thought using the Rect() would be the best for the task, however, It does not respond to autopage break. I also realize there is a logical error in my code but this is the only way I could get the 3 column output. I shall be glad to receive assistance correcting the errors in the code below. Thank you!
class PDF extends FPDF {
function Header(){
$this->SetFont('Arial', '', 10);
$this->Cell(18, 10, '', 0);
$this->SetFont('Arial', '', 9);
$this->Cell(35, 10, 'Date: '.date('d-m-Y').'', 0);
$this->Ln(12);
$this->SetFont('Arial', 'B', 11);
$this->Cell(70, 8, '', 0);
$this->Cell(100, 8, 'LIST', 0);
$this->Ln(13);
}
function Footer(){
$this->SetY(-15);
$this->SetFont('Arial','I',8);
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}
$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$staff = mysql_query("SELECT * FROM staff");
$item = 0;
$width = 60;
$height = 40;
$x = 15;
$y = 35;
$margin = 2;
while($a_staff = mysql_fetch_array($staff)){
$item = $item+1;
for($i = 0; $i < 3; $i++){
$pdf->Rect($x, $y, $width, $height, 'D');
$pdf->Image('images.gif' , $x+$margin ,$y+$margin, 25 , 25);
$x = ($x + $width + $margin);
}
$y = $y + $height + $margin;
$x = 15;
}
$pdf->Output( "report.pdf", "I" );
?>