Everything is written in the title.
I did not find any resource showing how to do it. I create a PDF document with FPDF for a PHP site. I added the page number in the footer but I can't add the current date in the format: "Monday 18 April 2022".
See the code :
class PDF extends FPDF { function Header() {}
function Footer() {
// Positionnement à 1,5 cm du bas
$this->SetY(-15);
// Police Arial italique 8
$this->SetFont('Arial','I',8);
// Numéro de page
$this->Cell(0,10,'Page '.$this->PageNo().' sur {nb}',0,0,'R');
}
}
$pdf = new PDF('P','mm','A4');
I can't enter php code in the Footer() class, and i can't even put php variables prepared beforehand.
Thanks for your help !
CodePudding user response:
Another call to $this->Cell()
will allow you to insert a date to your footer. The third argument will be the date string which you can generate with PHP using the inbuilt date()
function or date objects. The parameters for the Cell
method are explained in the FPDF docs at http://www.fpdf.org/ under manual
.
CodePudding user response:
Well, in the end I found it!
Here is the code :
function Footer() {
// Positionnement à 1,5 cm du bas
$this->SetY(-15);
// Police Arial italique 8
$this->SetFont('Arial','I',8);
// Date du jour
setlocale(LC_TIME, "");
date_default_timezone_set('Europe/Paris');
$date_du_jour = utf8_encode(strftime('%A %d %B %Y'));
$this->Cell(0,10,$date_du_jour,0,0,'L');
// Numéro de page
$this->Cell(0,10,'Page '.$this->PageNo().' sur {nb}',0,0,'R');
}