php FPDF 边界线

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15680052/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 09:43:50  来源:igfitidea点击:

FPDF borderlines

phpbordercellfpdf

提问by Ardilla

I used to make some very simple PDF with this library, FPDF, and now I'm trying to make a "result page" and it have to show something like this image, but with a border surrounding it all, not every cell.

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

a border must surround all the variables

边框必须包围所有变量

I already got that in FPDF, made will Cells (don't know if it's the best way for doing it), and code goes like this (for the moment I added the results by hand, just to figure out how it will look like):

我已经在 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);
}

Hope you can help me how to border all thouse results in one, I'm not beign able to do it, and didn't find anything.

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

Thanks again for your time, as always!!!

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

回答by Shamitha

You can use

您可以使用

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

Options

选项

  • D - Draw Line
  • F - Fill
  • DF or FD - Draw Line and Fill
  • D - 画线
  • F - 填充
  • DF 或 FD - 画线和填充

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

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

回答by Ardilla

Thanks for your time, but I finally found the way to make it. On border option from the cell, I added "LT", "RT"... and I could made a border-line that surrounds all (may not the best way to make it, if you know another and better way to make it, I would appreciate that).

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

Hope this can help other people that wishes to do the same!

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

回答by Ulfgar Hammerschlag

Your should first draw an empty Cell with a border surrounding it, then you can store your Y Position and reset the PDF positions and begin to draw your cells within your border Cell. Like this:

您应该首先绘制一个带有边框的空单元格,然后您可以存储您的 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');
...

Hope this helps :)

希望这可以帮助 :)

回答by bharat

//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');

回答by user3826569

Use FancyRow plugin of fpdf,to give the border or create the box If you need check the link here, it might help you. and the another plugin you can use here is table with multicell, check this link.

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