Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FPDF print MultiCell() adjacently

Tags:

I've googled around and found this question very common but I can't seem to find a proper and direct answer. I'm using FPDF and I want to generate tables using MultiCell() since I need the line break property of it. Tried Cell() but it can't read the line break.

$col1="PILOT REMARKS\n\n";
$pdf->MultiCell(189, 10, $col1, 1, 1);
$col2="Pilot's Name and Signature\n".$name;
$pdf->MultiCell(63, 10, $col2, 1);
$pdf->Ln(0);
$col3="Date Prepared\n".$date;
$pdf->MultiCell(63, 10, $col3, 1);

But I can't generate it properly 'cause MultiCell() stacks the result. How can I achieve having MultiCell() printed adjacently with each other in a most simple and easy way?

Found this similar question but it doesn't provide a clear answer. Any help will be appreciated. Thanks in advance.

like image 504
xjshiya Avatar asked Nov 26 '12 05:11

xjshiya


1 Answers

Try storing the X and Y co-ordinates and then setting them after the write

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

$col1="PILOT REMARKS\n\n";
$pdf->MultiCell(189, 10, $col1, 1, 1);

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

$col2="Pilot's Name and Signature\n".$name;
$pdf->MultiCell(63, 10, $col2, 1);
$pdf->Ln(0);
$col3="Date Prepared\n".$date;
$pdf->MultiCell(63, 10, $col3, 1);
like image 56
Danny Avatar answered Oct 01 '22 02:10

Danny