Creating Color Table in FPDF Tamil


Tables

Creating Color Table.

It can be expressed in RGB components or gray scale. The method can be called before the first page is created and the value is retained from page to page.

Parameters
  • r - red component Value between 0 and 255.
  • g - Green component (between 0 and 255).
  • b - Blue component (between 0 and 255).

if without red component, indicates the gray level.

SetFillColor

Defines the color used for all drawing operations (lines, rectangles and cell borders).

Syntax


SetFillColor([int r, [int g , int b])

SetDrawColor

Defines the color used for all drawing operations (lines, rectangles and cell borders).

Syntax


SetDrawColor([int r, [int g , int b])

SetTextColor

Defines the color used for text.

Syntax


SetTextColor([int r, [int g , int b])

Source Code

<?php
    require_once "fpdf/fpdf.php"; //fpdf supporting file
 
    $pdf = new FPDF('P','mm','A4');
    /*
        A4 - 210 * 297 mm
 
    */
    $pdf -> AddPage();
 
    //addFont(family,style,file)
    $pdf -> addFont('Roboto','','Roboto.php'); 
    $pdf -> SetFont('Roboto','',12);
 
    // Creating White Background. (Default background Fill  is black)
    $pdf -> SetFillColor(255, 255, 255); 
    $pdf -> SetDrawColor(0, 0, 255); // Creating Blue Bottom Border
 
 
    $pdf -> Cell(190,10,'Using Fill and Draw Color','B',1,'C',true);
    $pdf -> Cell(190,20,'',0,1,'C',false);
 
    $pdf -> SetFillColor(117, 117, 255);
    $pdf -> SetTextColor(255, 255, 255);
    $pdf -> SetDrawColor(117, 117, 255);
 
    $pdf -> Cell(190,10,'Using Fill,text and Draw Color',0,1,'C',true);
    $pdf -> Cell(190,20,'',0,1,'C',false);
 
    $pdf -> Cell(190,10,'Student Mark List',0,1,'C',true);
 
    $pdf -> SetTextColor(56, 56, 56);
 
    //  Column Titles
    $pdf -> Cell(38,7,'SNO',1,0,'C');
    $pdf -> Cell(38,7,'NAME',1,0,'C');
    $pdf -> Cell(38,7,'MARK 1',1,0,'C');
    $pdf -> Cell(38,7,'MARK 2',1,0,'C');
    $pdf -> Cell(38,7,'MARK 3',1,1,'C');
 
    //  Row Datas
    $pdf -> Cell(38,7,'1',1,0,'C');
    $pdf -> Cell(38,7,'Ram',1,0,'');
    $pdf -> Cell(38,7,'98',1,0,'C');
    $pdf -> Cell(38,7,'97',1,0,'C');
    $pdf -> Cell(38,7,'91',1,1,'C');
 
    $pdf -> Cell(38,7,'2',1,0,'C');
    $pdf -> Cell(38,7,'Mithran',1,0,'');
    $pdf -> Cell(38,7,'95',1,0,'C');
    $pdf -> Cell(38,7,'87',1,0,'C');
    $pdf -> Cell(38,7,'77',1,1,'C');
 
    $pdf -> Cell(38,7,'3',1,0,'C');
    $pdf -> Cell(38,7,'Mithwin',1,0,'');
    $pdf -> Cell(38,7,'97',1,0,'C');
    $pdf -> Cell(38,7,'95',1,0,'C');
    $pdf -> Cell(38,7,'93',1,1,'C');
 
 
 
 
    $pdf -> Output(); // Display output
?>
View Demo