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