问题描述
iam在PHP中使用FDPF的初学者.我搜索了很多,但找不到解决方案
我需要像这样的输出
但是我的代码的输出是
代码:
$row1a=mysql_fetch_array($sql_1a); $row1b=mysql_fetch_array($sql_1b); $row1c=mysql_fetch_array($sql_1c); $pdf->Cell(6,6," 1 a) ",0,0); $x = $pdf->GetX(); $y = $pdf->GetY(); $pdf->MultiCell(150,6,"{$row1a['Question']}",0,1); $pdf->SetXY($x + 160, $y); $pdf->Cell(6,6,"{$row1a['Mark']}",0,1); $pdf->Cell(6,6," b) ",0,0); $x = $pdf->GetX(); $y = $pdf->GetY(); $pdf->MultiCell(150,6,"{$row1b['Question']}",0,1); $pdf->SetXY($x + 160, $y); $pdf->Cell(6,6,"{$row1b['Mark']}",0,1); $pdf->Cell(6,6," c) ",0,0); $x = $pdf->GetX(); $y = $pdf->GetY(); $pdf->MultiCell(150,6,"{$row1c['Question']}",0,1); $pdf->SetXY($x + 160, $y); $pdf->Cell(6,6,"{$row1c['Mark']}",0,1);
其中$ row1a,$ row1b,$ row1c是用于从数据库中获取问题和标记的变量. 由于问题可以是从数据库中获取的可变长度,因此它与下一个问题重叠.
预先感谢.
推荐答案
在重叠的行上尝试一下:
$height = round(strlen($row1b['Question']) / 35); $height = ($height < 1 ? 1 : $height); $height = $height * 6; $pdf->MultiCell(150,$height,"{$row1b['Question']}",0,1);
其他推荐答案
执行GetY()每次MultiCell()呼叫之后进行更新(这每次向下推动当前y值),并为每次MultiCell()>.
问题描述
Iam a beginner in using fdpf in php . I have searched a lot but couldn't find the solution
I need to get output like this
but the output of my code is
the code:
$row1a=mysql_fetch_array($sql_1a); $row1b=mysql_fetch_array($sql_1b); $row1c=mysql_fetch_array($sql_1c); $pdf->Cell(6,6," 1 a) ",0,0); $x = $pdf->GetX(); $y = $pdf->GetY(); $pdf->MultiCell(150,6,"{$row1a['Question']}",0,1); $pdf->SetXY($x + 160, $y); $pdf->Cell(6,6,"{$row1a['Mark']}",0,1); $pdf->Cell(6,6," b) ",0,0); $x = $pdf->GetX(); $y = $pdf->GetY(); $pdf->MultiCell(150,6,"{$row1b['Question']}",0,1); $pdf->SetXY($x + 160, $y); $pdf->Cell(6,6,"{$row1b['Mark']}",0,1); $pdf->Cell(6,6," c) ",0,0); $x = $pdf->GetX(); $y = $pdf->GetY(); $pdf->MultiCell(150,6,"{$row1c['Question']}",0,1); $pdf->SetXY($x + 160, $y); $pdf->Cell(6,6,"{$row1c['Mark']}",0,1);
where $row1a,$row1b,$row1c are the variables used to fetch the question and marks from database. Since the question can be of variable length fetched from database , it overlaps with the next question.
Thanks in advance.
推荐答案
try this on the overlapping row:
$height = round(strlen($row1b['Question']) / 35); $height = ($height < 1 ? 1 : $height); $height = $height * 6; $pdf->MultiCell(150,$height,"{$row1b['Question']}",0,1);
其他推荐答案
Perform a GetY() update after every MultiCell() call (this pushes the current Y value every time downwards) and recalculate it properly for every further MultiCell().