重叠在PHP的fpdf输出中 [英] Overlap in the fpdf output in php
本文介绍了重叠在PHP的fpdf输出中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是在php中使用fdpf的初学者.我进行了很多搜索,但找不到解决方法
Iam a beginner in using fdpf in php . I have searched a lot but couldn't find the solution
我需要这样的输出
但是我的代码的输出是
代码:
$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是用于从数据库中获取问题和标记的变量. 由于问题可以是从数据库中获取的可变长度的问题,因此它与下一个问题重叠.
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.
谢谢.
推荐答案
在每次MultiCell()
调用之后执行一次GetY()
更新(这每次向下推当前的Y值),并在以后的MultiCell()
中正确地重新计算它
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()
.
这篇关于重叠在PHP的fpdf输出中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文