FPDF:在最后一页添加评论

FPDF: Add Comment at the last page

目前,我创建了一个系统,可以生成从 MySQL 到 pdf 的数据。显示为pdf的数据排列是:

1) 第一页只会显示1行数据

2) 第2页以后每页最多显示3行数据。

显示成功。现在,在页面末尾创建了一个评论框。问题是,评论框显示在数据行的末尾。我要

$pdf->SetFont('Arial','',10);
$user = $conn->query("
SELECT * 
  FROM ot_users u
  JOIN ot_team t
    on u.team_id = t.team_id 
 WHERE u.team_id = '".$_GET['team']."' 
   AND u.roles_id IN(4,5) 
 ORDER 
    BY u.roles_id ASC
");
  while ($row = $user->fetch(PDO::FETCH_ASSOC)){
      $pdf->Cell(20,8,$row['badgeid'],1,0);
      $pdf->Cell(154,8,$row['fullname'],1,1); 
  }
  $pdf->Cell(0,10,'',0,1,"C");

$user3 = $conn->query("
SELECT * 
  FROM ot_report r
  LEFT 
  JOIN ot_users u 
    ON r.badgeid = u.badgeid 
  LEFT 
  JOIN ot_team t
    ON t.team_id = u.team_id 
WHERE t.team_id = '".$_GET['team']."' 
   AND report_date BETWEEN '".$_GET["from"]."' AND '".$_GET["to"]."' 
 ORDER 
    BY r.report_date DESC
");
    $count = 0;
    while ($row = $user3->fetch(PDO::FETCH_ASSOC)){

        $pdf->SetFont('Arial','B',10);
        $pdf->Cell(20,7,'Date:',1,0);
        $pdf->Cell(67,7,date('d-m-Y',strtotime($row['report_date'])),1,0);
        $pdf->Cell(20,7,'Time:',1,0);
        $pdf->Cell(34,7,"From: ".date('H:i',strtotime($row['ot_start'])),1,0);
        $pdf->Cell(33,7,"To: ".date('H:i',strtotime($row['ot_end'])),1,1); 
        $pdf->Cell(87,7,'Before',1,0,'C');
        $pdf->Cell(87,7,'After',1,1, 'C');

        $logo = file_get_contents('../../images/faces/noimage.png');

        if(!isset($row['photo_before']) || empty($row['photo_before'])) {
          $pdf->Cell(87, 57, $pdf->MemImage($logo, $pdf->GetX()+20, $pdf->GetY()+5, 47,47,), 1, 0, 'C');
        }else{ 
          //$pdf->Cell(87, 57, $pdf->MemImage(base64_decode($row['photo_before']), $pdf->GetX()+21, $pdf->GetY()+2, 45,53,), 1, 0, 'C');
          $pdf->Cell(87, 57, $pdf->Image($row['photo_before'], $pdf->GetX()+21, $pdf->GetY()+2, 45,53,), 1, 0, 'C');
        }

        if(!isset($row['photo_after']) || empty($row['photo_after'])) {
          $pdf->Cell(87, 57, $pdf->MemImage($logo, $pdf->GetX()+20, $pdf->GetY()+5, 47,47,), 1, 1, 'C');
        }else{ 
          //$pdf->Cell(87, 57, $pdf->MemImage(base64_decode($row['photo_after']), $pdf->GetX()+21, $pdf->GetY()+2, 45,53,), 1, 1, 'C');
          $pdf->Cell(87, 57, $pdf->Image($row['photo_before'], $pdf->GetX()+21, $pdf->GetY()+2, 45,53,), 1, 0, 'C');
        }

        if ($row['time_photo_before'] == null){
          $pdf->Cell(87,7,'-',1,0, 'C');
        }else{
          $pdf->Cell(87,7,$row['time_photo_before'],1,0, 'C');
        }

        if ($row['time_photo_after'] == null){
          $pdf->Cell(87,7,'-',1,1, 'C');
        }else{
          $pdf->Cell(87,7,$row['time_photo_after'],1,1, 'C');
        }

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


          $pdf->AddPage();
          $pdf->Cell(60,7,'',0,1,"C");

        }

      $count++;

    }
    // Editing starts
    $leftPageMargin = 10;
    $heightAfterRows = 10;
    $pdf->SetXY($leftPageMargin, $pdf->GetY() + $heightAfterRows);
    // Editing ends
    $pdf->Cell(0,60,"Comment",1,1, 'L');

谁能帮帮我?

希望这对您有所帮助,并且我理解您的问题:

您可以在发表评论之前尝试此操作。

$leftPageMargin = 10;
$heightAfterRows = 10;
$pdf->SetXY($leftPageMargin, $pdf->GetY() + $heightAfterRows);