使用FPDF和PHP水平对齐多个图像
我正在从mysql数据库检索我的图像,并使用FPDF打印到我的PDF。我的问题是我希望我的MemImages从左到右排成一行,而不是在彼此下面,以便在打印时节省空间。请您提前帮助并感谢您。我的代码如下使用FPDF和PHP水平对齐多个图像,php,Php,我正在从mysql数据库检索我的图像,并使用FPDF打印到我的PDF。我的问题是我希望我的MemImages从左到右排成一行,而不是在彼此下面,以便在打印时节省空间。请您提前帮助并感谢您。我的代码如下 $resultImage = mysql_query("SELECT * FROM DBImage WHERE projectSectionId = '$projectSectionId' AND userId = '$userId' AND date = '$date' AND time = '
$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);
}
}
我终于得到了答案,并为另一个将面临同样问题的开发人员解职。下面是我的答案
$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);
}
}