I want to create a footer for a PDF document that contains the date left aligned, the creator centered and the page right aligned. These should be in a single line. I tried the following code:
$this->Cell(0, 10, $date->format('d.m.Y'), 0, false, 'L', 0, '', 0, false, 'T', 'M');
$this->Cell(0, 10, 'Creator', 0, false, 'C', 0, '', 0, false, 'T', 'M');
$this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'R', 0, '', 0, false, 'T', 'M');
The creator is shifted to the right and overlays with the pages:
Does anybody have a solution for that problem?
You need to set the width of the Cell()
, as according to the docs http://www.tcpdf.org/doc/code/classTCPDF.html#a33b265e5eb3e4d1d4fedfe29f8166f31 your $date->format('d.m.Y')
Cell()
is extending to the right margin, forcing the other cells on the line to the right margin.
$w (float) Cell width. If 0, the cell extends up to the right margin.
Try something like (may have to adjust based on font size)
$this->Cell(20, 10, $date->format('d.m.Y'), 0, false, 'L', 0, '', 0, false, 'T', 'M');
$this->Cell(20, 10, 'Creator', 0, false, 'C', 0, '', 0, false, 'T', 'M');
$this->Cell(20, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'R', 0, '', 0, false, 'T', 'M');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With