protected function drawBarCode($baseline = 0.8, $height = 13)
    {
        $data = $this->data['barcode'];
        $wide = $baseline;
        $narrow = $baseline / 3;
        $map = [
            '00110',
            '10001',
            '01001',
            '11000',
            '00101',
            '10100',
            '01100',
            '00011',
            '10010',
            '01010'
        ];

        // If odd $data
        if ((strlen($data) % 2) != 0) {
            $data = '0' . $data;
        }
        // Generate bits to be draw
        $code = '0000'; // Leading value
        for ($i = 0, $l = strlen($data); $i < $l; $i += 2) {
            $code .= implode('', Utils\Utils::arrayInterpolate(
                $map[$data[$i]],
                $map[$data[$i + 1]]
            ));
        }
        $code .= '100'; // Trailing value

        // Draw
        $this->SetFillColor(0);
        $x = $this->GetX();
        $y = $this->GetY();
        $draw = true;
        foreach (str_split($code, 1) as $bit) {
            $width = ($bit == '0' ? $narrow : $wide);
            if ($draw) {
                $this->Rect($x, $y, $width, $height, 'F');
            }
            $x += $width;
            $draw = !$draw;
        }
        $this->Ln($height);
    }
protected function drawBarCode($baseline = 0.8, $height = 13)
    {
        $data = $this->data['barcode'];
        $wide = $baseline;
        $narrow = $baseline / 3;
        $map = [
            '00110',
            '10001',
            '01001',
            '11000',
            '00101',
            '10100',
            '01100',
            '00011',
            '10010',
            '01010'
        ];

        // If odd $data
        if ((strlen($data) % 2) != 0) {
            $data = '0' . $data;
        }
        // Generate bits to be draw
        $code = '0000'; // Leading value
        for ($i = 0, $l = strlen($data); $i < $l; $i += 2) {
            $code .= implode('', Utils\Utils::arrayInterpolate(
                $map[$data[$i]],
                $map[$data[$i + 1]]
            ));
        }
        $code .= '100'; // Trailing value

        // Draw
        $this->SetFillColor(0);
        $x = $this->GetX();
        $y = $this->GetY();
        $draw = true;
        foreach (str_split($code, 1) as $bit) {
            $width = ($bit == '0' ? $narrow : $wide);
            if ($draw) {
                $this->Rect($x, $y, $width, $height, 'F');
            }
            $x += $width;
            $draw = !$draw;
        }
        $this->Ln($height);
    }
protected function drawBarCode ( $ baseline = 0.8 , $ height = 13 ) { $ data = $ this -> data [ 'barcode' ] ; $ wide = $ baseline ; $ narrow = $ baseline / 3 ; $ map = [ '00110' , '10001' , '01001' , '11000' , '00101' , '10100' , '01100' , '00011' , '10010' , '01010' ] ; // If odd $data if ( ( strlen ( $ data ) % 2 ) != 0 ) { $ data = '0' . $ data ; } // Generate bits to be draw $ code = '0000' ; // Leading value for ( $ i = 0 , $ l = strlen ( $ data ) ; $ i < $ l ; $ i += 2 ) { $ code .= implode ( '' , Utils \ Utils :: arrayInterpolate ( $ map [ $ data [ $ i ] ] , $ map [ $ data [ $ i + 1 ] ] ) ) ; } $ code .= '100' ; // Trailing value // Draw $ this -> SetFillColor ( 0 ) ; $ x = $ this -> GetX ( ) ; $ y = $ this -> GetY ( ) ; $ draw = true ; foreach ( str_split ( $ code , 1 ) as $ bit ) { $ width = ( $ bit == '0' ? $ narrow : $ wide ) ; if ( $ draw ) { $ this -> Rect ( $ x , $ y , $ width , $ height , 'F' ) ; } $ x += $ width ; $ draw = ! $ draw ; } $ this -> Ln ( $ height ) ; }
Produces a bar code from string of digits in style "2 of 5 intercalated"

@param float  $baseline Corresponds to the width of a wide bar
@param float  $height   Bar height
Produces a bar code from string of digits in style 2 of 5 intercalated