mrssoft/barcode

Barcode coder

Installs: 4

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 1

Open Issues: 0

Type:yii2-extension

1.0.0 2018-05-08 07:01 UTC

This package is auto-updated.

Last update: 2024-04-08 15:15:41 UTC


README

Documentation

Installation

The preferred way to install this extension is through composer. Either run

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

or add

"mrssoft/barcode": "*"

to the require section of your composer.json file.

Usage

    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();
    }