我正在Zend 1.12应用程序中生成条形码图像。
我遵循教程示例#5使用渲染器对象渲染条形码
我在控制器
中编写了以下代码function barcodeAction()
{
$barcodeOptions = array('text' => 'ZEND-FRAMEWORK');
// No required options
$rendererOptions = array();
// Draw the barcode in a new image,
// send the headers and the image
Zend_Barcode::factory(
'code39', 'image', $barcodeOptions, $rendererOptions
)->render();
}
当访问条形码动作时——条形码图像不显示
下面是我从view source
得到的html<img style="-webkit-user-select: none" src="http://localhost/zend1.12/public/index/barcode">
让我知道我做错了什么
我终于想通了你需要禁用视图——写入
$this->_helper->viewRenderer->setNoRender();
在行动中解决问题
还注意到传递给条形码的文本需要大写
$barcodeOptions = array('text' => 'ZEND-FRAMEWORK'); // This is valid
$barcodeOptions = array('text' => 'Zend-Framework'); // This is not valid