I used the Zend barcode library to generate barcodes for the items in my Codeigniter project. I used the following codes :
public function book_barcode($product_code = NULL, $bcs = 'code128', $height = 60)
{
return "<img src='" . site_url('item/gen_barcode/' . $product_code . '/' . $bcs . '/' . $height) . "' alt='{$product_code}' class='bcimg' />";
}
function gen_barcode($product_code = NULL, $bcs = 'code128', $height = 60, $text = 1)
{
$drawText = ($text != 0) ? FALSE : TRUE;
$this->load->library('zend');
$this->zend->load('Zend/Barcode');
$barcodeOptions = array('text' => $product_code, 'barHeight' => $height, 'drawText' => $drawText, 'factor' => 1.0);
header("Content-Type: image/svg+xml");
if (0) {
$rendererOptions = array('imageType' => 'jpg', 'horizontalPosition' => 'center', 'verticalPosition' => 'middle');
$imageResource = Zend_Barcode::render($bcs, 'image', $barcodeOptions, $rendererOptions);
return $imageResource;
} else {
$rendererOptions = array('renderer' => 'svg', 'horizontalPosition' => 'center', 'verticalPosition' => 'middle');
$imageResource = Zend_Barcode::render($bcs, 'svg', $barcodeOptions, $rendererOptions);
return $imageResource;
}
}
all the sections are working correctly without preview the generated barcodes. The generated barcode images are as follows :

What lines of codes are missed by me ? Can anyone help ?