mrssoft/barcode

条码编码器

安装: 4

依赖关系: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 1

开放性问题: 0

类型:yii2-extension

1.0.0 2018-05-08 07:01 UTC

This package is auto-updated.

Last update: 2024-09-08 16:11:52 UTC


README

文档

安装

安装此扩展的首选方式是通过 composer。运行以下命令之一

php composer.phar require --prefer-dist mrssoft/barcode "*"

或者在您的 composer.json 文件的 require 部分添加

"mrssoft/barcode": "*"

使用方法

    public function actionBarcode($ean13 = null, $width = 250, $height = 100)
    {
        $im = imagecreatetruecolor($width, $height);
        $black = imagecolorallocate($im, 0x00, 0x00, 0x00);
        $white = imagecolorallocate($im, 0xff, 0xff, 0xff);
        imagefilledrectangle($im, 0, 0, $width, $height, $white);

        if (!empty($ean13)) {
            Barcode::gd($im, $black, $width / 2, $height / 2, 0, 'ean13', $ean13, 2, $height);
        }

        header('Content-Type: image/png');
        imagepng($im);
        imagedestroy($im);
        eixt();
    }