Source for file BarcodeObject
Documentation is available at BarcodeObject 
//============================================================+  
// File name   : barcode.php  
// Last Update : 2005-01-02  
// Author      : Karim Mribti [barcode@mribti.com]  
// Version     : 1.1 [0.0.8a (original code)]  
// License     : GNU LGPL (Lesser General Public License) 2.1  
//               http://www.gnu.org/copyleft/lesser.txt  
// Source Code : http://www.mribti.com/barcode/  
// Description : Generic Barcode Render Class for PHP using  
//               the GD graphics library.  
// This version contains changes by Nicola Asuni:  
//  - code style and formatting  
//  - automatic php documentation in PhpDocumentor Style  
//  - $mCharSet and $mChars variables were added here  
//============================================================+  
 * Barcode Render Class for PHP using the GD graphics library.  
 * @author Karim Mribti, Nicola Asuni  
 * @package linea21.externals  
 * @subpackage com.tecnick.tcpdf  
 * @version 0.0.8a 2001-04-01 (original code)  
 * @license http://www.gnu.org/copyleft/lesser.html LGPL  
 * option: generate barcode border  
 * option: use transparent background  
define("BCS_ALIGN_CENTER", 4);  
define("BCS_ALIGN_RIGHT", 16);  
 * option: generate JPEG image  
 * option: generate PNG image  
define("BCS_STRETCH_TEXT", 256);  
define("BCS_REVERSE_COLOR", 512);  
define("BCS_I25_DRAW_CHECK", 2048);  
 * set default background color  
define("BCD_DEFAULT_BACKGROUND_COLOR", 0xFFFFFF);  
 * set default foreground color  
define("BCD_DEFAULT_FOREGROUND_COLOR", 0x000000);  
 * set default style options  
define("BCD_DEFAULT_STYLE", BCS_BORDER |  BCS_ALIGN_CENTER |  BCS_IMAGE_PNG);  
define("BCD_DEFAULT_WIDTH", 460);  
define("BCD_DEFAULT_HEIGHT", 120);  
define("BCD_DEFAULT_FONT", 5);  
 * st default horizontal resolution  
define("BCD_DEFAULT_XRES", 2);  
define("BCD_DEFAULT_MAR_Y1", 0);  
define("BCD_DEFAULT_MAR_Y2", 0);  
 * set default text offset  
define("BCD_DEFAULT_TEXT_OFFSET", 2);  
define("BCD_I25_NARROW_BAR", 1);  
define("BCD_I25_WIDE_BAR", 2);  
define("BCD_C39_NARROW_BAR", 1);  
define("BCD_C39_WIDE_BAR", 2);  
 * Barcode Render Class for PHP using the GD graphics library.  
 * @author Karim Mribti, Nicola Asuni  
 * @package linea21.externals  
 * @version 0.0.8a 2001-04-01 (original code)  
 * @license http://www.gnu.org/copyleft/lesser.html LGPL  
   * @var Image width in pixels.  
   * @var Image height in pixels.  
   * @var Numeric code for Barcode style.  
   * @var Numeric code for character font.  
   * @param int $Width Image width in pixels.  
   * @param int $Height Image height in pixels.  
   * @param int $Style Barcode style.  
  public function __construct($Width= BCD_DEFAULT_WIDTH, $Height= BCD_DEFAULT_HEIGHT, $Style= BCD_DEFAULT_STYLE) {  
    $this->mBgcolor =  ImageColorAllocate($this->mImg, ($dbColor & 0xFF0000) >>  16,  
    ($dbColor & 0x00FF00) >>  8, $dbColor & 0x0000FF);  
    $this->mBrush =  ImageColorAllocate($this->mImg, ($dfColor & 0xFF0000) >>  16,  
    ($dfColor & 0x00FF00) >>  8, $dfColor & 0x0000FF);  
   * Returns the image object.  
   * Abstract method used to draw the barcode image.  
   * @param int $xres Horizontal resolution.  
    /* there is not implementation neded, is simply the asbsract function. */  
   * Draws the barcode border.  
   * Draws the alphanumeric code.  
   * @param int $Font Font type.  
   * @param int $xPos Horiziontal position.  
   * @param int $yPos Vertical position.  
   * @param int $Char Alphanumeric code to write.  
  protected function DrawChar($Font, $xPos, $yPos, $Char) {  
    ImageString($this->mImg,$Font,$xPos,$yPos,$Char,$this->mBrush);  
   * Draws a character string.  
   * @param int $Font Font type.  
   * @param int $xPos Horiziontal position.  
   * @param int $yPos Vertical position.  
   * @param int $Char string to write.  
  protected function DrawText($Font, $xPos, $yPos, $Char) {  
    ImageString($this->mImg,$Font,$xPos,$yPos,$Char,$this->mBrush);  
   * Draws a single barcode bar.  
   * @param int $xPos Horiziontal position.  
   * @param int $yPos Vertical position.  
   * @param int $xSize Horizontal size.  
   * @param int $xSize Vertical size.  
   * @return bool trur in case of success, false otherwise.  
    if ($xPos>= 0 &&  $xPos<= $this->mWidth &&  ($xPos+ $xSize)<= $this->mWidth &&   
    $yPos>= 0 &&  $yPos<= $this->mHeight &&  ($yPos+ $ySize)<= $this->mHeight) {  
      for ($i= 0;$i< $xSize;$i++ ) {  
        ImageLine($this->mImg, $xPos+ $i, $yPos, $xPos+ $i, $yPos+ $ySize, $this->mBrush);  
   * Returns the current error message.  
   * @return string error message.  
   * Returns the font height.  
   * @param int $font font type.  
   * @return int font height.  
    return ImageFontHeight($font);  
   * Returns the font width.  
   * @param int $font font type.  
   * @return int font width.  
    return ImageFontWidth($font);  
   * @param int $font font type.  
   * @return int barcode style.  
   * @param int $Style barcode style.  
   * Flush the barcode image.  
      Header("Content-Type: image/png");  
      Header("Content-Type: image/jpeg");  
   * Destroy the barcode image.  
    ImageDestroy($this->mImg);  
//============================================================+  
//============================================================+  
 
 
        
       |