【问题标题】:How can I use a multiline footer in TCPDF?如何在 TCPDF 中使用多行页脚?
【发布时间】:2019-05-17 03:01:11
【问题描述】:
// Page footer
public function Footer() {
    // Position at 15 mm from bottom
    $this->SetY(-15);
    // Set font
    $this->SetFont('helvetica', 'I', 8);
    // Page number
    $this->Cell(0, 10, 'Seite '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
}

现在我的页脚看起来像这样:

]

但我需要一个更复杂的多行页脚:

]

我怎样才能做到这一点?

我试图用这个堆栈溢出建议来解决它:

TCPDF Multiple Footers

但我没有成功。

【问题讨论】:

    标签: php tcpdf


    【解决方案1】:

    尝试将MultiCell 与一些单元格宽度组合一起使用,如下所示:

    public function Footer() {
        // Make more space in footer for additional text
        $this->SetY(-25);
    
        $this->SetFont('helvetica', 'I', 8);
    
        // Page number
        $this->Cell(0, 10, 'Seite '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
    
        // New line in footer
        $this->Ln(8);
    
        // First line of 3x "sometext"
        $this->MultiCell(55, 10, 'Sometext', 0, 'C', 0, 0, '', '', true, 0, false, true, 10, 'M');
        $this->MultiCell(55, 10, 'Sometext', 0, 'C', 0, 0, '', '', true, 0, false, true, 10, 'M');
        $this->MultiCell(55, 10, 'Sometext', 0, 'C', 0, 0, '', '', true, 0, false, true, 10, 'M');
    
        // New line for next 3 elements
        $this->Ln(4);
    
        // Second line of 3x "sometext"
        $this->MultiCell(55, 10, 'Sometext', 0, 'C', 0, 0, '', '', true, 0, false, true, 10, 'M');
        $this->MultiCell(55, 10, 'Sometext', 0, 'C', 0, 0, '', '', true, 0, false, true, 10, 'M');
        $this->MultiCell(55, 10, 'Sometext', 0, 'C', 0, 0, '', '', true, 0, false, true, 10, 'M');
    
        // and so on...
    }
    

    我使用来自 github 的最新 TCPDF 库做了一个活生生的例子,你可以在页脚看到上面代码的结果:

    https://so.wolfish.pl/tcpdf/footer.php

    更多关于如何使用MultiCell函数的例子可以在TCPDF官方例子中看到:https://tcpdf.org/examples/example_005/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-04
      • 1970-01-01
      • 2016-03-08
      • 2011-02-18
      • 1970-01-01
      • 2017-12-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多