So, my problem is that i'm using FPDF to create a pdf file from php. Just one problem. Once text is too large for a cell it doesn't wrap. So i came to the point to try to use multicells, but there is another problem. Once a cell is wrapped in a table i got no way to get the other multicells to the same height.
Here is the code i tested.
<?php
require('../fpdf181/fpdf.php');
$pdf = new FPDF('P', 'mm', 'A4');
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Arial', '', 14);
$x = $pdf->GetX();
$y = $pdf->GetY();
$push_right = 0;
$pdf->MultiCell(50,10,"TEST shdfkjhdsafhahsjdkfkhjshakjfhdsdsfhkjdkjhsafhkjdakjhsfhkjdskjhaf", "TBRL");
$pdf->SetXY($x+50, $y);
$pdf->MultiCell(50,10,"TEST shdfkjhdsafhahsjdkfkhjshakjfhdsdsfhkjdsafsdafdsafsdafsdafddkjhsafhkjdakjhsfhkjdskjhaf", "TBRL");
$pdf->Output();
From that code i got this:
But it should look like this:
This is how it works, for those who have the same problem:
function MultiCellRow($cells, $width, $height, $data, $pdf)
{
$x = $pdf->GetX();
$y = $pdf->GetY();
$maxheight = 0;
for ($i = 0; $i < $cells; $i++) {
$pdf->MultiCell($width, $height, $data[$i]);
if ($pdf->GetY() - $y > $maxheight) $maxheight = $pdf->GetY() - $y;
$pdf->SetXY($x + ($width * ($i + 1)), $y);
}
for ($i = 0; $i < $cells + 1; $i++) {
$pdf->Line($x + $width * $i, $y, $x + $width * $i, $y + $maxheight);
}
$pdf->Line($x, $y, $x + $width * $cells, $y);
$pdf->Line($x, $y + $maxheight, $x + $width * $cells, $y + $maxheight);
}
To execute the function I used: MultiCellRow(3, 50, 10, ["Cell1","Cell2", "Cell3"], $pdf);