Position Settings in FPDF Tamil


GetX()

Returns the abscissa of the current position.

Syntax


float GetX()

GetY()

Returns the ordinate of the current position.

Syntax


float GetY()

SetX()

Defines the abscissa of the current position. If the passed value is negative, it is relative to the right of the page.

Syntax


float SetX(float x)

SetY()

Sets the ordinate and optionally moves the current abscissa back to the left margin. If the value is negative, it is relative to the bottom of the page.

Syntax


float SetY(float y)

SetXY()

Sets the ordinate and optionally moves the current abscissa back to the left margin. If the value is negative, it is relative to the bottom of the page.

Syntax


SetXY(float x, float y)

GetPageHeight()

Returns the current page height.

Syntax


float GetPageHeight()

GetPageWidth()

Returns the current page width.

Syntax


float GetPageWidth()

GetStringWidth()

Returns the length of a string in user unit. A font must be selected.

Syntax


float GetStringWidth(string)


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,'Positions','B',1,'C');
    $pdf -> Cell(190,5,'',0,1,'C',false);
 
    $x = $pdf -> GetX();
    $pdf -> Cell(100,10,"Current Position ( X ) : ".$x." cm",0,1);
 
    $y = $pdf -> GetY();
    $pdf -> Cell(50,10,"Current Position ( Y ) : ".$y." cm",0,1);
 
    $pdf -> SetX(10);
    $pdf -> SetY(145);
    $pdf -> Cell(0,5,"X Position : ".$pdf -> GetX()." cm - Y Position : ".$pdf -> GetY()." cm",0);
 
    $pdf -> SetXY(30,170);
    $pdf -> Cell(0,5,"X Position : ".$pdf -> GetX()." cm - Y Position : ".$pdf -> GetY()." cm",0);
    $pdf -> Cell(190,15,'',0,1,'C',false);
 
    $h = $pdf -> GetPageHeight();
    $pdf -> Cell(100,10,"Height of the Page : ".$h." mm",0,1);
 
    $w = $pdf -> GetPageWidth();
    $pdf -> Cell(50,10,"Width of the Page : ".$w." mm",0,1);
    $pdf -> Cell(190,15,'',0,1,'C',false);
 
    $len = $pdf -> GetStringWidth('Tutor Joes');
    $pdf -> Cell(21,10,"Tutor Joes",0,1);
    $pdf -> Cell(100,10,"String Length : ".$len." mm",0,1);
 
 
    $pdf -> Output(); // Display output
?>
View Demo