1

我曾经用这个库 FPDF 制作了一些非常简单的 PDF,现在我正在尝试制作一个“结果页面”,它必须显示类似这张图片的内容,但它周围有一个边框,而不是每个单元格。

边框必须围绕所有变量

我已经在 FPDF 中得到了它,制作了 Will Cells(不知道这是否是最好的方法),代码是这样的(目前我手动添加了结果,只是为了弄清楚它的样子):

//SimpleTable
function SimpleTable() {
    $this->Cell(280,15,"Inscription Number: 1",0);
    $this->Cell(265,15,"Date: 28/03/2008",0);
    $this->Ln();
    $this->Cell(265,15,"Name and Surname: Name Surname ",0);
    $this->Cell(265,15,"",0);
    $this->Ln();
    $this->Cell(280,15,"Address: Address",0);
    $this->Cell(265,15,"",0);
    $this->Ln();
    $this->Cell(280,15,"Zip Code: Zip Code",0);
    $this->Cell(280,15,"City: City",0);
    $this->Ln();
    $this->Cell(280,15,"Year of birth: Birthday",0);
    $this->Cell(280,15,"Age: Age",0);
    $this->Ln();
    $this->Cell(280,15,"VIP: No - First Time: Yes",0);
    $this->Cell(280,15,"School: My school",0);
}

希望您能帮助我如何将所有结果合并为一个,我无法做到这一点,也没有找到任何东西。

再次感谢您的时间,一如既往!!!!

4

6 回答 6

2

您可以使用

Rect(StartX, StartY, Width, Height, Options)

选项

  • D - 画线
  • F - 填充
  • DF 或 FD - 画线和填充

例子$pdf->Rect(0, 0, 210, 100, 'D');

于 2014-11-06T14:50:20.927 回答
1
//The BorderBox
$actual_position_y = $pdf->GetY();
$pdf->SetFillColor(255, 255, 255);
$pdf->SetDrawColor(0, 0, 0);
$pdf->Cell($your_content_width, $your_content_heigth, "", 1, 1, 'C');

//Your actual content
$pdf->SetXY($yourLeftosition, $actual_position_y);
$pdf->Cell($cellwidth, $cellheigth, "Inscription Number", 0, 1, 'C');
于 2014-11-22T19:27:31.617 回答
0

使用 fpdf 的 FancyRow 插件,给边框或创建框如果你需要检查这里的链接,它可能会帮助你。您可以在此处使用的另一个插件是带有多单元格的表格,请查看此链接

于 2014-11-29T07:00:29.023 回答
0

谢谢你的时间,但我终于找到了办法。在单元格的边框选项上,我添加了“LT”,“RT”......我可以制作一个围绕所有内容的边框线(如果您知道另一种更好的制作方法,可能不是最好的制作方法,我会很感激)。

希望这可以帮助其他希望做同样的人!

于 2013-03-28T11:46:36.677 回答
0

您应该首先绘制一个带有边框的空单元格,然后您可以存储您的 Y 位置并重置 PDF 位置并开始在您的边框单元格内绘制您的单元格。像这样:

//The BorderBox
$actual_position_y = $pdf->GetY();
$pdf->SetFillColor(255, 255, 255);
$pdf->SetDrawColor(0, 0, 0);
$pdf->Cell($your_content_width, $your_content_heigth, "", 1, 1, 'C');

//Your actual content
$pdf->SetXY($yourLeftosition, $actual_position_y);
$pdf->Cell($cellwidth, $cellheigth, "Inscription Number", 0, 1, 'C');
...

希望这可以帮助 :)

于 2014-02-17T09:07:15.397 回答
0

以上都不起作用。可以使用 cell() 方法中的第 4 个参数来完成。第 4 个参数可以将边框设置为:

L: left
T: top
R: right
B: bottom

您可以用逗号分隔以任何顺序提供它们。因此,在您的情况下,您可以将“L,T,R”作为第 4 个参数,如下所示:

$this->Cell(280,15,"Inscription Number: 1","L,T,R");
$this->Cell(265,15,"Date: 28/03/2008","L,T,R");

仅中间部分“L,R”

$this->Cell(265,15,"Name and Surname: Name Surname ","L,R");
$this->Cell(265,15,"","L,R");

和底部的一个

$this->Cell(280,15,"VIP: No - First Time: Yes","L,R,B");
$this->Cell(280,15,"School: My school","L,R,B");
于 2020-11-18T15:04:42.123 回答