如何使用TCPDF为每个页面设置不同的页眉/页脚?

时间:2017-08-17 15:11:43

标签: php tcpdf

我正在尝试使用TCPDF为每个页面设置不同的页脚。我目前正在使用自定义页眉和页脚,但我还没弄明白如何为每个页面设置不同的页脚。这可能吗?

public function Footer() {

    $this->SetTextColor(168,163,163);

    // Position at 15 mm from bottom
    $this->SetY(-17);
    // Set font
    $this->SetFont('roboto', 'N', 10);

    $this->Cell(0, 10, 'Something', 0, false, 'L', 0, '', 0, false, 'T', 'M');

    $image_file = K_PATH_IMAGES."logo_example.jpg";
    $this->Image($image_file, 96, 272, 15, '', 'JPG', '', 'C', false, 300, '', false, false, 0, false, false, false);

    // Page number
    $this->Cell(12, 10, 'página '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'R', 0, '', 0, false, 'T', 'M');
}

1 个答案:

答案 0 :(得分:0)

只需根据页码创建一个条件:

if ($this->getAliasNumPage() == "1")
  $this->Cell(0, 10, 'Something only on the first page', 0, false, 'L', 0, '', 0, false, 'T', 'M');