I’ve been working on this FPDF document for a year now. It works beautifully except for the last portion.
I have the last page as a mini photo gallery and I’ve used MultiCell to place the date, caption & image into a cell which is dynamically filled from MySql database. My problem is that when there are more than 5 photos, the cells go off the page to the right instead of moving to a new line.
I’ve tried placing the MultiCells on a new line for each photo, but when the end of the page is reached, the image is at the bottom of the previous page while the date and caption are on the next page.
Here is the code:
$sqld = "SELECT id, image, thumb, image_type, caption, site_no, img_date, rate FROM images WHERE site_no=$site AND rate>0 ORDER BY img_date";
$resultd = mysqli_query($dbcon, $sqld) or die(mysqli_error());
$pdf->AddPage();
$pdf->SetFont('Arial','B',11);
$pdf->SetFillColor(225,225,225);
$pdf->Cell(270,6,'E. Photo Gallery:',1,1,'L',1);
$pdf->Ln(2);
$pdf->SetFont('Arial', 'I', 9);
while($runImage = $resultd->fetch_assoc()) {
if(empty($image)){
}else{
{
$array[] =$runImage;
$image_height = 36;
$image_width = 48;
$image_height2 = 6;
$image_width2 = 48;
//get current X and Y
$start_x = $pdf->GetX();
$start_y = $pdf->GetY();
$pdf->SetFillColor(255,255,255);
// place image and move cursor to proper place. "+ 2" added for buffer
$pdf->MultiCell(48, 3, $runImage['img_date'] . ' - ' . $runImage['caption'] . $pdf->Image('uploads/thumbs/'.$runImage['image'],$pdf->GetX(), $pdf->GetY(),$image_width,$image_height, 'jpg'), 0, 1, 'L');
$pdf->SetXY($start_x + $image_width + 2, $start_y);
} // End of Gallery else Statement
} // End of Gallery foreach Statement
$pdf->SetFillColor(225,225,225);
} //-------------- End of If(Image) Gallery ---------------
Please can someone help me?
Thank you