PHP code example of mrssoft / barcode

1. Go to this page and download the library: Download mrssoft/barcode library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mrssoft / barcode example snippets


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

php composer.phar