官网地址http://www.barcodephp.com/en/userguide
我现在想将这个方法打包成函数,然后传数值进去,返回的是html代码,例如这种字符串
php codefunction barcode($listing) { // including all required classes require_once('class/bcgfontfile.php'); require_once('class/bcgcolor.php'); require_once('class/bcgdrawing.php'); // including the barcode technology require_once('class/bcgcode39.barcode.php'); // loading font $font = new bcgfontfile('./class/font/arial.ttf', 18); // the arguments are r, g, b for color. $color_black = new bcgcolor(0, 0, 0); $color_white = new bcgcolor(255, 255, 255); $drawexception = null; try { $code = new bcgcode39(); $code->setscale(2); // resolution $code->setthickness(30); // thickness $code->setforegroundcolor($color_black); // color of bars $code->setbackgroundcolor($color_white); // color of spaces $code->setfont($font); // font (or 0) $code->parse($listing); // text } catch(exception $exception) { $drawexception = $exception; } /* here is the list of the arguments 1 - filename (empty : display on screen) 2 - background color */ $drawing = new bcgdrawing('', $color_white); if($drawexception) { $drawing->drawexception($drawexception); } else { $drawing->setbarcode($code); $drawing->draw(); } // header that says it is an image (remove it if you save the barcode to a file) header('content-type: image/png'); // draw (or save) the image into png format. $drawing->finish(bcgdrawing::img_format_png); }
------解决方案--------------------
1、糟糕!此链接好像已损坏
2既然有
header('content-type: image/png');
// draw (or save) the image into png format.
$drawing->finish(bcgdrawing::img_format_png);
那么差生的是图片数据流
所以产生 的工作是你自己的事情
