Nasim Bahar
Nasim Bahar

Reputation: 115

How to generate barcode in CodeIgniter-3.0rc2 using zend barcode library

Here is my controller and view. image is not return by controller.before this I used codeignter version 2.2 . there work properly but in the CodeIgniter-3.0rc2 is not working.

<img src="<?php echo base_url('index.php/barcode');?>"  alt="not show" style="margin-top:20px; margin-left:90%;"/>

below is my controller:

<?php
class barcode extends MY_Controller {

    public function index()
    {
        //I'm just using rand() function for data example
        $this->load->library('zend');
        $this->zend->load('Zend/Barcode');

        $barcodeOptions = array('text' => 'ZEND-FRAMEWORK');
        $rendererOptions = array('imageType'          =>'png', 
                                 'horizontalPosition' => 'center', 
                                 'verticalPosition'   => 'middle');
        $imageResource= Zend_Barcode::factory('code39', 'image', $barcodeOptions, $rendererOptions)->render();
        return $imageResource;   
    }
}
?>

output is not show

Upvotes: 2

Views: 6842

Answers (2)

dEsta88
dEsta88

Reputation: 119

thanks for using my library..

Check this issue : https://github.com/desta88/Codeigniter-Barcode-Generator-Zend-Library/issues/1 (The EXT constant has been removed on CI 3)

Just change constant, from EXT to '.php', in your libraries/Zend.php

Or

Download here, I've been updated from this issue : http://api.mdesain.com/Codeigniter-Barcode-Generator-Zend-Library/barcode.zip

Upvotes: 1

Mike Miller
Mike Miller

Reputation: 3129

Using return is incorrect. You should be able to just do:

Zend_Barcode::factory('code39', 'image', $barcodeOptions, $rendererOptions)->render();

And this should display the image on screen.

Upvotes: 1

Related Questions