Create display barcode using codeigniter with library zend barcode

假如想象 提交于 2021-02-11 05:10:38

问题


I tried to make the barcode degnan using zend library barcode , barcode appear when running perfectly but his display case full , how to display results in a barcode into an iframe or img ???

This my Controller

class Contohbarcode extends CI_Controller {

    function __construct() {
        parent::__construct();
    }

function index() {
    $this->load->view('insertcode');
}

function bikin_barcode() {
    $this->load->library('zend');
    $this->zend->load('Zend/Barcode');

    $barcode = $this->input->post('barcode');
    Zend_Barcode::render('code128', 'image', array('text'=>$barcode), array());
}

}

View insertcode

<form method="post" action="<?php echo base_url(); ?>contohbarcode/bikin_barcode" class="form-horizontal">
    <div align="center">
    <input name="barcode" id="location" type="text"  placeholder="insert your code">
    </p>
    <input type="submit" class="btn" name="submit" value="Find">
    </div>
</form> 

回答1:


First you need to save it to variable and then save it to file using e.g. imagepng, and then you can display that barcode as simple image

$imageResource = Zend_Barcode::factory('code128', 'image', array('text'=>$barcode), array())->draw();
imagepng($imageResource, 'public_html/img/barcode.png');

Zend tutorial about saving barcode to imageResource

PHP.net about imagepng



来源:https://stackoverflow.com/questions/35646567/create-display-barcode-using-codeigniter-with-library-zend-barcode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!