我已经google了一下,发现这个问题很常见,但我似乎无法找到一个正确而直接的答案.我正在使用FPDF,我想使用MultiCell()生成表,因为我需要它的换行属性.试过Cell()但它无法读取换行符.
$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);
Run Code Online (Sandbox Code Playgroud)
但我无法正确生成它'因为MultiCell()堆栈结果.如何以最简单,最简单的方式相互打印MultiCell()?
发现这个类似的问题,但它没有提供明确的答案.任何帮助将不胜感激.提前致谢.
小智 38
尝试存储X和Y坐标,然后在写入后设置它们
$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);
Run Code Online (Sandbox Code Playgroud)
小智 6
只是为了添加Danny的答案.我喜欢保存每列的宽度,然后在执行SetXY方法时使用它.
例:
$x = $this->x;
$y = $this->y;
$push_right = 0;
$this->MultiCell($w = 100,3,"Column\r\nNumber 1",1,'C',1);
$push_right += $w;
$this->SetXY($x + $push_right, $y);
$this->MultiCell($w = 60,3,"Column\r\nNumber 2",1,'C',1);
$push_right += $w;
$this->SetXY($x + $push_right, $y);
$this->MultiCell(0,3,"Column 3\r\nFilling in the Rest",1,'C',1);
Run Code Online (Sandbox Code Playgroud)