【问题标题】:FPDF borderlinesFPDF 边界线
【发布时间】:2013-03-28 11:00:21
【问题描述】:

我曾经用这个库 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);
}

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

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

【问题讨论】:

    标签: php border cell fpdf


    【解决方案1】:

    你可以使用

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

    选项

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

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

    【讨论】:

      【解决方案2】:
      //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');
      

      【讨论】:

        【解决方案3】:

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

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

        【讨论】:

          【解决方案4】:

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

          希望这会有所帮助:)

          【讨论】:

            【解决方案5】:

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

            【讨论】:

              【解决方案6】:

              以上都不起作用。 可以使用 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");
              

              【讨论】:

                猜你喜欢
                • 1970-01-01
                • 1970-01-01
                • 2021-04-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 2016-06-13
                • 2017-11-11
                相关资源
                最近更新 更多