[英]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');
}
Right now my footer looks like this: 现在,我的页脚如下所示:
]
]
But I need a more komplex footer with multiple lines: 但是我需要一个多行的komplex页脚:
]
]
How can I achieve this? 我该如何实现?
I tried to solve it with this stack overflow suggestion: 我试图通过以下堆栈溢出建议解决它:
TCPDF Multiple Footers TCPDF多页脚
But I had no success. 但是我没有成功。
Try using MultiCell
with some cell width combination, like this: 尝试将
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...
}
I made a live example of this using newest TCPDF lib from github, you can see result of above code here in the footer: 我使用来自github的最新TCPDF库制作了一个实时示例,您可以在页脚中看到以上代码的结果:
https://so.wolfish.pl/tcpdf/footer.php https://so.wolfish.pl/tcpdf/footer.php
You can see more examples of how to use MultiCell
function in TCPDF official examples: https://tcpdf.org/examples/example_005/ 您可以在TCPDF官方示例中查看有关如何使用
MultiCell
函数的更多示例: https : MultiCell
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.