问题描述
我已经搜索了谷歌搜索,发现这个问题很普遍,但我似乎找不到正确而直接的答案.我使用的是FPDF,并且想使用Multicell()生成表,因为我需要它的线路断开属性.尝试的单元格(),但无法读取线路断开.
$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);
,但我无法正确生成它,因为Multicell()堆叠结果.如何以最简单,最简单的方式将Multicell()彼此相邻打印?
找到此类似的问题但这并不能提供明确的答案.任何帮助将不胜感激.提前致谢.
推荐答案
尝试存储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);
其他推荐答案
只是为了添加到 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);
其他推荐答案
您可以使用setxy(x,y)函数在pdf中设置光标.
$pdf->SetXY(x,y);
设置光标以在PDF
中打印数据其中x为x轴值,y为y轴值
问题描述
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.
推荐答案
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);
其他推荐答案
Just to add to Danny's answer. I like keeping the Width of each column stored and then use that when executing the SetXY method.
Example:
$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);
其他推荐答案
You can use SetXY(x,y) function to set cursor in pdf .
$pdf->SetXY(x,y);
Set cursor to print data in pdf
Where x is x-axis value and y is y-axis value