Good day!

I found a sample code in generating barcode.

here's the link:


and this is the code:

$number = isset($_GET['number']) ? $_GET['number'] : '';

$barcode_font = dirname(__FILE__).'/fonts/FREE3OF9.TTF';
$plain_font   = dirname(__FILE__).'/fonts/plain.pfb';

$width = 200;
$height = 80;

$img = imagecreate($width, $height);

// First call to imagecolorallocate is the background color
$white = imagecolorallocate($img, 255, 255, 255);
$black = imagecolorallocate($img, 0, 0, 0);

// Reference for the imagettftext() function
// imagettftext($img, $fontsize, $angle, $xpos, $ypos, $color, $fontfile, $text);
imagettftext($img, 36, 0, 10, 50, $black, $barcode_font, $number);

imagettftext($img, 14, 0, 40, 70, $black, $plain_font, $number);

header('Content-type: image/png');


fisrt i got an error at because I don't have plain.pfb, i don't know where i can download that font. and when I tried to change it to pala.tff and I run the code the error was gone bt the output is blank.

I need to create a barcode. It's my first time to create a barcode using php.

Any help is highly appreciated.

Thank you so much.