【问题标题】:How can I render a Zend_Barcode inside a html page?如何在 html 页面中呈现 Zend_Barcode?
【发布时间】:2012-05-23 20:21:55
【问题描述】:

我的一个应用程序使用 Codeignitor 开发并使用 Zend_Barcode 库创建条形码,

参考:http://www.beyondcoding.com/2008/02/21/using-zend-framework-with-codeigniter/

如何在 codeignitor 视图上显示条形码。 试过了,

// Only the text to draw is required
$barcodeOptions = array('text' => 'NOT-ME');

// No required options
$rendererOptions = array();

// Draw the barcode in a new image,
$imageResource = Zend_Barcode::draw(
    'code39', 'image', $barcodeOptions, $rendererOptions
);

$data['barcode'] = imagejpeg($imageResource, 'barcode.jpg', 100);

// Free up memory
imagedestroy($imageResource); 

在视图中

<img src="<?php echo $barcode;?>">

但它失败了:(

【问题讨论】:

  • 您使用的是什么版本的 Zend?较新的版本在使用 codeigniter 时存在一些问题。我猜是依赖问题。
  • 以下答案是否有帮助?

标签: codeigniter barcode


【解决方案1】:

代替

Zend_Barcode::draw('code39', 'image', $barcodeOptions, $rendererOptions);

使用

Zend_Barcode::render('code39', 'image', $barcodeOptions, $rendererOptions);

【讨论】:

  • 如果使用上述脚本我们需要在视图或控制器中添加库?
  • 库及以上代码应添加到控制器中。上一行之前的代码: $this->load->library('zend'); $this->zend->load('Zend/条形码');
猜你喜欢
  • 2018-08-04
  • 2013-12-03
  • 2019-10-14
  • 1970-01-01
  • 2021-02-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多