Image in FPDF Tamil


Image

Display an image. The size it will take on the page can be specified in different ways

  • Explicit width and height
  • One explicit dimension, the other being calculated automatically in order to keep the original proportions
  • No explicit dimension, in which case the image is put at 96 dpi

Supported formats are JPEG, PNG and GIF. The GD extension is required for GIF.

Syntax


Image(string file [, float x [, float y [, float w [, float h [, string type [, mixed link]]]]]])

Features

  • For JPEGs, all flavors are allowed they are gray scales,true colors (24 bits),CMYK (32 bits)
  • For PNGs, allowed flavors are gray scales on at most 8 bits (256 levels),indexed colors,true colors (24 bits)
  • Transparency is supported.
  • The format can be specified explicitly or inferred from the file extension.
  • It is possible to put a link on the image.
  • if an image is used several times, only one copy is embedded in the file.
  • If height or width value is positive, it represents the user unit. If the value is negative, the absolute value represents the vertical or horizontal resolution in dpi. If the value is not specified or equal to zero, it is automatically calculated
Parameters
  • file - Abscissa of first point.
  • x - Ordinate of first point.
  • y - Abscissa of second point.
  • w - Ordinate of second point.
  • h - Ordinate of second point.
  • type - Image format. Possible values are (case insensitive): JPG, JPEG, PNG and GIF. If not specified, the type is inferred from the file extension.
  • link - URL or identifier returned by AddLink().

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,'Place Image','B',1,'C');
      $pdf -> Cell(190,5,'',0,1,'C',false);
 
     //Image(string file [,float x [,float y [, float w [, float h [, string type [, mixed link ]]]]]])
/*----------------------Place Image-------------------------------------*/	
     //Image(string file)
     $pdf -> Image("img/logo.png");
/*----------------------Place Image with x and y-------------------------------------*/	
    //Image(string file,x,y)
    $pdf -> Image("img/logo.png",50,50);
    /*----------------------Place Image with x,y,height,width and type-------------------------------------*/	
    //Image(string file,x,y)
    $pdf -> Image("img/logo.png",50,120,10,20,'PNG');
 
 
    $pdf -> Output(); // Display output
?>
View Demo