Reputation: 362
I am in the process of converting 2 Cells into MultiCells for the purpose of text wrapping within FPDF. I have followed a post on here which I found very useful to get the 2 MultiCells side by side. The problem I have is that the MultiCell is within a foreach statement and it overlaps the next MultiCell if the previous MultiCell has multiple lines. I have tried a couple of options so far including adding onto the height of the MultiCell but I need them to have appropriate height for the content within them.
Then I though well I need to work out the height of each MultiCell and add that too GetY. I found the code for GetMultiCellHeight() but when trying to use this I remembered that this adds to the position of the current MultiCell and not the position of the NEXT MultiCell. And this is where I got stuck!
This is the code I have so far:
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");
}
}
Any help on how I can pass the height of the current MultiCell for use with the next MultiCell would be greatly appreciated!
Kind Regards,
n00bstacker
Upvotes: 0
Views: 4083
Reputation: 362
Looks like the script Table with MultiCells on fpdf.org is exactly what I need. Thanks Oliver!
Upvotes: 1