What is the purpose of {AliasNbPages} in FPDF and how does it help in generating page numbers in a PDF document?

The {AliasNbPages} in FPDF is a placeholder that allows for dynamic generation of page numbers in a PDF document. It helps in automatically updating the total number of pages in the document as pages are added or removed. By using this placeholder in the header or footer of the PDF document, you can ensure that the page numbers are always accurate.

// Initialize FPDF
require('fpdf.php');
$pdf = new FPDF();

// Add a page
$pdf->AddPage();

// Set the header
$pdf->SetHeader('{AliasNbPages}');

// Set the footer
$pdf->SetFooter('Page {PageNo} of {AliasNbPages}');

// Output the PDF
$pdf->Output();