Line Settings in FPDF Tamil


Line

Draws a line between two points.

Syntax


Line(float x1, float y1, float x2, float y2)

Parameters
  • x1 - Abscissa of first point.
  • y1 - Ordinate of first point.
  • x2 - Abscissa of second point.
  • y2 - Ordinate of second point.

SetLineWidth

Defines the line width. By default, the value equals 0.2 mm. The method can be called before the first page is created and the value is retained from page to page.

Syntax


SetLineWidth(float width)

Rect

Creating a rectangle. It can be drawn (border only), filled (with no border) or both..

Syntax


Rect(float x, float y, float w, float h [, string style])

Parameters
  • x1 - Abscissa of upper-left corner.
  • y1 - Ordinate of upper-left corner.
  • x2 - Width.
  • y2 - Height.
style

Style of rendering. Possible values are:

  • D or empty string: draw. This is the default value.
  • F: fill
  • DF or FD: draw and fill

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);
 
 
    $pdf -> Cell(190,10,'Draw lines','B',1,'C');
    $pdf -> Cell(190,5,'',0,1,'C',false);
/*----------------------Create Line-------------------------------------*/	
    //line(x1,y1,x2,y2)
    $pdf -> Line(20,45,150,45);
 
    $pdf -> Ln(10);
/*----------------------Change Line Width-------------------------------------*/	
 
    $pdf -> SetLineWidth(2.0);
    $pdf -> Line(20,65,150,65);
/*----------------------Change Line color-------------------------------------*/	
    $pdf -> SetDrawColor(117, 117, 255);
    $pdf -> SetLineWidth(1.5);
    $pdf -> Line(20,75,20,115);
/*----------------------Rectangle-------------------------------------*/	
 
    $pdf -> SetDrawColor(255, 0, 0);    
    //Rect(x, y, width, height, 'D');
    $pdf -> Rect(25,120,30,30,'D');
    $pdf -> Rect(25,160,30,30,'F');
    $pdf -> Rect(25,200,30,30,'DF');
    //OR
    $pdf -> Rect(25,240,30,30,'FD');
    //without fill
    $pdf -> Rect(125,200,30,30);
 
 
    $pdf -> Output(); // Display output
?>
View Demo