【问题标题】:FPDF: Add some text at the END of the pageFPDF:在页面末尾添加一些文本
【发布时间】:2019-12-05 01:44:15
【问题描述】:

我想在 PDF 的最后一页添加一些文本,例如“准备者”。在我的例子中,我在第一页显示 2 行数据,从第二页开始显示 3 行数据。

我遇到的问题是,如果最后一页只有 1 或 2 行数据,“准备者”将显示在同一页面上。但是,如果最后一页有 3 行数据,则“准备者”将显示在下一页,即空白页(无数据行)。以下是我的代码:

      $count = 0;
      while ($row = mysqli_fetch_array($user3)){
        //rendering row.....
        //.....

          if ((($count - 4) % 3) === 0) {

            $pdf->AddPage();

          }

        $count++;
      }

      $pdf->Cell(0,5,'',0,1,"C");
      $pdf->Cell(63,8,'Prepared by,',0,0,"C");

  $pdf->Output();

谁能知道问题出在哪里以及如何解决?

【问题讨论】:

    标签: php mysql fpdf


    【解决方案1】:

    你可以尝试添加这个。

          $count = 0;
          while ($row = mysqli_fetch_array($user3)){
            //rendering row.....
            //.....
    
              if ((($count - 4) % 3) === 0) {
    
                $pdf->AddPage();
    
              }
    
            $count++;
    function Footer()
    {
        // Position at 1.5 cm from bottom
        $this->SetY(-15);
        // Arial italic 8
        $this->SetFont('Arial','I',8);
        // Page number
        $this->Cell(0,10,'Prepared by: Your Name');
    }
    }
      $pdf->Output();
    

    【讨论】:

    • @incongnitorecon 我收到以下错误:无法重新声明页脚()(之前在中声明
    • @RadamelFalcao 你能提供完整的代码,因为我不知道你把你​​的页脚放在哪里
    • 你可以和我聊天吗?
    猜你喜欢
    • 1970-01-01
    • 2016-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-09
    • 1970-01-01
    • 2013-04-05
    相关资源
    最近更新 更多