Margins in FPDF Tamil


SetMargins

Defines the left, top and right margins. By default, they equal 1 cm. Call this method to change them.

Syntax


SetMargins([float left, float top , [ float right])

Parameters
  • left- left margin
  • top- left margin
  • right- Right margin. Default value is the left one./li>

$pdf->SetMargins(3,3);


SetLeftMargin

Defines the left margin. The method can be called before creating the first page.

Syntax


SetLeftMargin([float margin)

example

$pdf->SetLeftMargin(7);


SetTopMargin

Defines the top margin. The method can be called before creating the first page.

Syntax


SetTopMargin(float margin)

example

$pdf->SetTopMargin(7);


SetRightMargin

Defines the right margin. The method can be called before creating the first page.

Syntax


SetRightMargin(float margin)

example

$pdf->SetRightMargin(7);


Source Code

<?php
	require_once "fpdf/fpdf.php"; //fpdf supporting file
 
	$pdf = new FPDF('P','mm','A4');
 
/*-------------------Create Margin for Entire Document---------------*/
	$pdf -> SetMargins(25.4,25.4);
	$pdf -> AddPage();
 
    //addFont(family,style,file)
       $pdf -> addFont('Roboto','','Roboto.php'); //Adding Custom Font
       $pdf -> SetFont('Roboto','',10);
 
 
 
	$pdf -> Cell(130,5,'Tutor Joes - Oerall Margin',1,1,'C');
/*-------------------Create Right Margin for Entire Document---------------*/
	$pdf -> SetRightMargin(15);
	$pdf -> AddPage();
 
	$pdf -> Cell(50,5,'Tutor Joes - Right Margin',1,1,'R');
 
/*-------------------Create Left Margin for Entire Document---------------*/
	$pdf -> SetLeftMargin(60);
	$pdf -> AddPage();
 
	$pdf -> Cell(50,5,'Tutor Joes - Left Margin',1,1);
 
/*-------------------Create Top Margin for Entire Document---------------*/
	$pdf -> SetTopMargin(60);
	$pdf -> AddPage();
 
	$pdf -> Cell(50,5,'Tutor Joes - Top Margin',1,1);
 
	$pdf -> Output(); // Display output
?>
View Demo