First, you need to download a barcode font. Here is a freeware one:
http://www.squaregear.net/fonts/free3of9.shtml

Save it to a folder on your server, and place the following code in a
file in the same folder as the font and name it for example "barcode.php":

<?php
        // specify a barcode font
        $barcodeFont="./FREE3OF9.TTF";

        // check that a code is provided
        $code=$_GET['code'];
        $size=$_GET['size'];
        if($code==''){
                exit;
        }
        if($size==''){
                $size=20;
        }
        
        // image width and height
        $width=barcodeWidth($code, $size);
        $height=$size;
        
        // Set the content-type
        header("Content-type: image/png");
        
        // Create the image
        $im = imagecreatetruecolor($width, $height);
        
        // Create some colors
        $white = imagecolorallocate($im, 255, 255, 255);
        $black = imagecolorallocate($im, 0, 0, 0);
        imagefilledrectangle($im, 0, 0, $width-1, $height-1, $white);
        
        // The text to draw
        $text = "*$code*";
        
        // Add the text
        imagettftext($im, $size, 0, 0, $size, $black, $barcodeFont, $text);
        
        // Using imagepng() results in clearer text compared with imagejpeg()
        imagepng($im);
        imagedestroy($im);

        // function to retrieve barcode width
        function barcodeWidth($code, $size){
                global $barcodeFont;
                
                $arrInfo=imagettfbbox($size, 0, $barcodeFont, "*$code*");
                return ($arrInfo[2]-$arrInfo[0]);
        }
        

?>


To print a barcode into any webpage, insert this HTML code in the page:

<img src="barcode.php?code=123456">

Of course, '123456' should be replaced with whatever code youo wish to
display.

Regards,
Ahmad Gneady
BigProf Software
http://www.bigprof.com


--- In [email protected], ravee kumar <[EMAIL PROTECTED]> wrote:
>
> hi. 
> i have aregistration page in my website. once confirm the
registration i need to generate a barcode . i'l produce this as a
image to registered user. is there any one guide me to do this.
> 
> ravi
> 
>        
> ---------------------------------
> Get the Yahoo! toolbar and be alerted to new email wherever you're
surfing. 
> 
> [Non-text portions of this message have been removed]
>


Reply via email to