我正在从mysql数据库中检索我的图像并使用FPDF打印到我的PDF。我的问题是我希望我的MemImages从左到右排成一行而不是在彼此之下,以便在我打印时节省空间。可以请你请提前帮助和谢谢。我的代码如下。
$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);
}
}
答案 0 :(得分:1)
我终于得到了答案,也解决了其他将面临同样问题的开发人员。以下是我的答案。
$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);
}
}