html - PHP Content-Type not displaying bar code image -


i trying generate bar code using http://www.barcodebakery.com script not displaying bar code image. here 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 missing? when print $drawing value ‰png ihdrÊo%zÍ”ltextcopyrightgenerated barcode generator 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') not displaying image small icon.

your code should working follows examples user guide.

why trying print $drawing? open page in browser , should see generated barcode. explain

if have specified filename before, image saved file, otherwise displayed.

so, if want saved somewhere, add filename when needed.

$drawing = new bcgdrawing('/route/to/your/file.png', $colorback); 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

node.js - Using Node without global install -

php - CakePHP HttpSockets send array of paramms -