您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PHP生成条形码有关问题

2025/8/17 17:32:41发布29次查看
php生成条形码问题
官网地址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);
那么差生的是图片数据流
所以产生 的工作是你自己的事情
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product