【问题标题】:FPDF PHP using SetY footer displays on next page下一页显示使用 SetY 页脚的 FPDF PHP
【发布时间】:2021-03-12 15:33:50
【问题描述】:

在 FPDF 中使用 SetY 时,内容似乎不是基于页面底部放置的。我尝试使用他们的页脚示例:

class PDF extends FPDF
{


// Page footer
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,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}

也只是把它放在我页面的末尾:

//Regular page content
$pdf->Cell(40,10,'Apple and iPhone are trademarks of Apple Inc., registered in the U.S. and other countries.');

//Footer content
$pdf->SetY(-15);
// Arial italic 8
$pdf->SetFont('Arial','I',8);
// Page number
$pdf->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');

$pdf->Output();

但两者似乎都与pdf页面上已经加载的内容有关,而不是基于页面底部。如果页面内容为 40 行,页脚内容将加载到同一页面上。如果页面内容为 100 行,则页脚内容显示在新页面的顶部。

感谢任何输入。

【问题讨论】:

    标签: fpdf


    【解决方案1】:

    尝试将 Y 设置为正数。例如:$pdf->SetY(240); 它会将位置设置为页面顶部。

    【讨论】:

    • 嘿,这真的很棒!我不确定我是如何从底部获得非相对关系的,但现在我的页脚在每个页面上都存在,无论内容如何。谢谢!
    【解决方案2】:

    我迟到了 6 到 1/2 年,因为下一个遇到同样问题的可怜虫:

    我的解决方案是添加 $pdf->SetAutoPageBreak(false);

    不知道为什么底部的位置 Y 并不总是按预期工作,而是将新项目推送到新页面...但是关闭 AutoPageBreak() 对我来说是解决方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-28
      • 1970-01-01
      • 1970-01-01
      • 2013-09-24
      • 2013-07-27
      • 2013-04-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多