code igniter zend 条码库不工作
code igniter zend barcode library not working
我正在为我的 codeigniter 项目使用 Zend Barcode 库。
以前它工作正常。但是,现在我得到的是空白图像而不是条形码
我该如何解决这个问题?
控制器
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Printing extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->library('zend');
}
public function bar_code()
{
$page = 'barcode';
$ch_id = $this->session->user['church_id'];
$data['tbl_data'] = $this->print_model->members_barcode($ch_id);
$data['off_type'] = $off_type;
$data['church_name'] = $this->session->user['church_name'];
$data['main_content'] = 'print/'.$page;
$this->load->view('index', $data);
}
//Barcode Render
public function barcode($data)
{
$this->zend->load('zend/barcode');
Zend_Barcode::render(
'code128',
'image',
array(
'text' => $data,
'barHeight' => 35,
'drawText' => FALSE,
'withQuietZones' => FALSE,
'barWidth' => 100,
));
}
}
查看
<img class="br-img" src="<?php echo site_url('printing/barcode/'.$value->mem_tbl_id.$off_type); ?>" alt="">
预览
该功能是生成基于文件的数据而不是路径文件信息,因此您应该将视图更改为 link 生成的文件,因为 html 需要路径源
我正在为我的 codeigniter 项目使用 Zend Barcode 库。 以前它工作正常。但是,现在我得到的是空白图像而不是条形码 我该如何解决这个问题?
控制器
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Printing extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->library('zend');
}
public function bar_code()
{
$page = 'barcode';
$ch_id = $this->session->user['church_id'];
$data['tbl_data'] = $this->print_model->members_barcode($ch_id);
$data['off_type'] = $off_type;
$data['church_name'] = $this->session->user['church_name'];
$data['main_content'] = 'print/'.$page;
$this->load->view('index', $data);
}
//Barcode Render
public function barcode($data)
{
$this->zend->load('zend/barcode');
Zend_Barcode::render(
'code128',
'image',
array(
'text' => $data,
'barHeight' => 35,
'drawText' => FALSE,
'withQuietZones' => FALSE,
'barWidth' => 100,
));
}
}
查看
<img class="br-img" src="<?php echo site_url('printing/barcode/'.$value->mem_tbl_id.$off_type); ?>" alt="">
预览
该功能是生成基于文件的数据而不是路径文件信息,因此您应该将视图更改为 link 生成的文件,因为 html 需要路径源