PHP用barcode生成条形码

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_33729889/article/details/77574330

下载barcode

将项目放到网站根目录

示例代码

                require_once('./barcode/class/BCGColor.php');
		require_once('./barcode/class/BCGDrawing.php');
		require_once('./barcode/class/BCGcode128.barcode.php');
        $colorFront = new \BCGColor(0, 0, 0);
        $colorBack = new \BCGColor(255, 255, 255);

        // Barcode Part
        $font = new \BCGFontFile('./barcode/font/Arial.ttf', 14);
        $code = new \BCGcode128();
        $code->setScale(2);
        $code->setFont($font);
        $code->setColor($colorFront, $colorBack);
        $code->parse(I('code','error'));

        // Drawing Part
        $drawing = new \BCGDrawing('', $colorBack);
        $drawing->setBarcode($code);
        $drawing->draw();

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

        $drawing->finish(\BCGDrawing::IMG_FORMAT_PNG);



展开阅读全文

没有更多推荐了,返回首页