如何在 TCPDF 中使用多行页脚?
How can I use a multiline footer in TCPDF?
// 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
但是我没有成功。
尝试使用 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/
// 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
但是我没有成功。
尝试使用 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/