2014-11-02 56 views
0

为了在FPDF中进行文本换行,我正在将2个单元转换为MultiCells。我在这里发表了一篇文章,我发现非常有用的将两个MultiCells并排放置。我遇到的问题是MultiCell处于foreach语句中,如果以前的MultiCell有多行,它将与下一个MultiCell重叠。到目前为止,我已经尝试了几个选项,包括添加到MultiCell的高度,但我需要它们为其中的内容设置适当的高度。FPDF中的并排多层MultiCell

然后我很好,我需要计算出每个MultiCell的高度并添加GetY。我找到了GetMultiCellHeight()的代码,但试图使用它时,我记得这增加了当前MultiCell的位置,而不是NEXT MultiCell的位置。这就是我卡住的地方!

这是我到目前为止的代码:

foreach($final as $row){ 

// Only loop over the legal fee 
if($row['fee_scale_category_id'] == 3){ 

    $amount_total += $row['amount']; 
    $vat_total += $row['vat']; 
    $total_total += ($row['amount'] + $row['vat']); 
    $fee_amount = $row['amount']; 



    $pdf->SetX(10); 
    $pdf->SetFont('Arial','',9); 

    $x = $pdf->GetX(); 
    $y = $pdf->GetY(); 

    $multiCellHeight = $pdf->GetMultiCellHeight(80,6,$row['fee_scale_item'].':',0,"L"); 

    if ($multiCellHeight > 6) { 

     $pdf->SetXY($x, $y + $multiCellHeight); 

    } else { 

     $pdf->SetXY($x, $y); 

    } 

    $pdf->MultiCell(80,6,$row['fee_scale_item'].':',0,"L"); 

    if ($multiCellHeight > 6) { 

     $pdf->SetXY($x+ 80, $y + $multiCellHeight); 

    } else { 

     $pdf->SetXY($x + 80, $y); 

    } 

    $pdf->MultiCell(20,6,substr('£', 1, 1).round_me($row['amount'] + $row['vat']),0,"R"); 

} 

} 

我如何能传递当前的多单元的高度,下一个多单元使用任何帮助将不胜感激!

亲切的问候,

n00bstacker

回答