如何在tcpdf库中添加页脚

时间:2014-07-07 13:29:43

标签: pdf tcpdf

我使用tcpdf创建pdf,我想在页脚中添加版权文本,但是这个页脚文本显示在标题上方。这是代码

$this->MultiCell(0, 10, $wpptopdfopts['pdf_footer'], 0, false, 'C', 0, '', 0, false, 'T', 'M');

1 个答案:

答案 0 :(得分:0)

1.创建扩展TCPDF类的类:

    class YourPdfGenerator extends TCPDF {}

2.使用您的数据覆盖页脚方法:

public function Footer() {
    [...]
    $pagenumtxt = $this->l['w_page'] . ' ' . $this->getAliasNumPage() . ' / ' . $this->getAliasNbPages();
    $this->SetDrawColor(128, 128, 128);
    $this->Line(10, 264, 200, 264);
    $this->SetFont('myfont', '', 6);
    $this->SetTextColor(80, 80, 80);
    $this->SetXY(10, -32);
    $this->MultiCell(190, 10, $this->locale($this->lang->trans('report_label_offer_policy')), 0, 'L');
    $this->SetFont('myfont', '', 8);
    $this->SetXY(10, -14);
    $this->Cell(192, 10, $this->locale($date_now), 0, 0, 'L');
    $this->SetXY(10, -14);
    $this->Cell(190, 10, $pagenumtxt, 0, 0, 'R');
  }

3.Enjoy