Reputation: 41
I am retrieving my images from mysql database and printing to my PDF using FPDF.My problem is i want my MemImages to be in one line from left to right and not underneath each other to save space when i print.Can you please help and thank you in advance.My code is below.
$resultImage = mysql_query("SELECT * FROM DBImage WHERE projectSectionId = '$projectSectionId' AND userId = '$userId' AND date = '$date' AND time = '$time'");
while($runImage = mysql_fetch_assoc($resultImage))
{
$image = $runImage['image'];
if(empty($image)){
} else {
$pdf->Ln(2);
$pdf->MemImage($image);
$pdf->Ln(2);
}
}
Upvotes: 1
Views: 2869
Reputation: 41
I finally got the answer and for the sack of another developers who will face the same problem.Here is my answer below.
$resultImage = mysql_query("SELECT * FROM DBImage WHERE projectSectionId = '$projectSectionId' AND userId = '$userId' AND date = '$date' AND time = '$time'");
while($runImage = mysql_fetch_assoc($resultImage))
{
$array[] =$runImage;
$image = $runImage['image'];
$image_height = 45;
$image_width = 60;
//get current X and Y
$start_x = $pdf->GetX();
$start_y = $pdf->GetY();
if(empty($image)){
}else{
// place image and move cursor to proper place. "+ 2" added for buffer
$pdf->MemImage($runImage['image'],$pdf->GetX(), $pdf->GetY(),$image_width,$image_height);
$pdf->SetXY($start_x + $image_width + 2, $start_y);
}
}
Upvotes: 3