【问题标题】:Create display barcode using codeigniter with library zend barcode使用带有库 zend 条码的 codeigniter 创建显示条码
【发布时间】:2016-02-26 08:09:55
【问题描述】:

我尝试使用zend库条形码制作条形码,条形码在完美运行时出现但他的展示柜已满,如何将条形码中的结果显示到iframe或img中???

这是我的控制器

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

}

查看插入代码

<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> 

【问题讨论】:

    标签: php codeigniter zend-framework


    【解决方案1】:

    首先,您需要将其保存到变量中,然后使用例如将其保存到文件中。 imagepng,然后您可以将该条码显示为简单图像

    $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

    【讨论】:

    • 不错...这项工作,img 条形码存储在一个文件夹中,我可以显示。非常感谢@Gvidas
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多