I am trying to generate bar code using http://www.barcodebakery.com but my script is not displaying bar code image. Here is my code:
<?php
require_once('../barcodegen/class/BCGFontFile.php');
require_once('../barcodegen/class/BCGColor.php');
require_once('../barcodegen/class/BCGDrawing.php');
require_once('../barcodegen/class/BCGcode128.barcode.php');
//$font = new BCGFontFile('./barcodegen/class/font/Arial.ttf', 18);
$color_black = new BCGColor(0, 0, 0);
$color_white = new BCGColor(255, 255, 255);
// Barcode Part
$code = new BCGcode128();
$code->setScale(2);
$code->setThickness(30);
$code->setForegroundColor($color_black);
$code->setBackgroundColor($color_white);
//$code->setFont($font);
$code->setStart(NULL);
$code->setTilde(true);
$code->parse('123456');
// Drawing Part
$drawing = new BCGDrawing('', $color_white);
$drawing->setBarcode($code);
$drawing->draw();
header('Content-Type: image/png');
$drawing->finish(BCGDrawing::IMG_FORMAT_PNG);
?>
Is there anything that I am missing?
when I print $drawing I get value ‰PNG IHDRÊO%zÍ”LtEXtCopyrightGenerated with Barcode Generator for PHP http://www.barcodephp.comYp¸³IDATxœíØÑnƒ †QXöþ¯Ì.LQa¶ÝŸ.圫q2óµtZk¥”Zëþóf9Ïìö瞎ίx>«ŸÓ›¯áþÚæW¼sîÿæù ïßáùÌÑ çwr4çÑ¿ñëòð'äE¼’Aò"H^É‹ y$/‚äE¼’Aò"H^É‹ y$/‚äE¼’Aò"H^É‹ y$/‚äE¼’Aò"H^É‹ y$/‚äE¼’Aò"H^É‹ y$/‚äE¼’Aò"H^É‹ y$/‚äE¼’Aò"H^É‹ y$/‚äE¼ªµw¯e÷"H^É‹ y$/‚äEÐ÷»ð¯ÕZK)ço7Ûø¦?Ú_ž¸»×С•Ãxkm«gŸÖ-ËgÕkóýi>rçÐ"V8Žg£íç~+Ú*‹çu( ÖZëcÛùeC{”‹·U÷Ú_’ž3ÚŸ¼{íì^/;©³µöÄvøaÖÍkô’þܹ\ZúáØ{½m¯úuÚR–Þº_ú Fÿ3Ž*¼<ºò½Ý,iŽýb>ÌžúIEND®B
‚`
but header('Content-Type: image/png') is not displaying any image but just a small icon.