Header and Footer in FPDF Tamil


Header

This method is used to render the page header. It is automatically called by AddPage() and should not be called directly by the application. The implementation in FPDF is empty, so you have to subclass it and override the method if you want a specific processing.

Syntax


Header()

Footer

This method is used to render the page footer. It is automatically called by AddPage() and Close() and should not be called directly by the application. The implementation in FPDF is empty, so you have to subclass it and override the method if you want a specific processing.

Syntax


Footer()

AliasNbPages

Defines an alias for the total number of pages. It will be substituted as the document is closed. The alias. Default value: {nb}.

Syntax


AliasNbPages([string alias])

PageNo

Returns the current page number.

Syntax


int PageNo()

Ln

Performs a line break. The current abscissa goes back to the left margin and the ordinate increases by the amount passed in parameter.

Syntax


Ln([float h])

Parameters
  • h - The height of the break.By default, the value equals the height of the last printed cell.

Source Code

<?php
    require_once "fpdf/fpdf.php"; //fpdf supporting file
class PDF extends Fpdf
{
    // Page header
    function Header()
    {
        // Arial bold 15
       $this -> SetFont('Arial','B',8);
        // Move to the right (for Center Position)
       $this -> Cell(80);
        // Title
       $this -> Cell(30,3,'Tutor Joes',0,0,'C');
        // Line break
       $this -> Ln(10);
    }
    // Page footer
    function Footer()
    {
        // Position at 1.5 cm from bottom
       $this->SetY(-15);
        // Arial italic 8
       $this->SetFont('Arial','B',8);
        // Page number
       $this->Cell(0,10,'Page '.$this -> PageNo().'out of {nb}',0,0,'C');
    }
}
    $pdf = new PDF();
    /* A4 - 210 * 297 mm */
    $pdf -> AliasNbPages(); // Must for print total no of page
    $pdf -> AddPage();
 
    //addFont(family,style,file)
    $pdf -> addFont('Roboto','','Roboto.php'); 
    $pdf -> SetFont('Roboto','',12);
 
 
    $pdf -> Cell(190,10,'Set Your Title Here','B',1,'C');
    $pdf -> Cell(190,5,'',0,1,'C',false);
 
    for($i=1;$i<=70;$i++)
        $pdf->Cell(0,10,$i,0,1);
 
 
    $pdf -> Output(); // Display output
?>
View Demo