FPDF - Line


We can draw line in pdf documents by using Line() function in FPDF.

Syntax
Line($x1,$y1,$x2,$y2)

The following example shows, how to

  • Draw Horizontal Line
  • Change Line Thickness
  • Line with Border Color
  • Draw Vertical Line
Example
<?php
  require('fpdf/fpdf.php');

  $pdf=new FPDF("P","mm","A4");
  
  $pdf->AddPage();
  
  //simple Horizontal Line
  $pdf->Line(10,20,200,20);
  
  //Change Line Thickness
  $pdf->SetLineWidth(1);
  $pdf->Line(10,40,200,40);
  
  //Set Line Color
  $pdf->SetDrawColor(255,0,0);
  $pdf->Line(10,60,200,60);
  
  //Vertical Line
  $pdf->Line(50,80,50,200);
  
  $pdf->Output();
?>
Output