在 Zend 1.12 应用程序中生成条形码图像

Barcode image generating in Zend 1.12 application

我正在 Zend 1.12 应用程序中生成条码图像。

我正在学习教程Example #5 Renderering a barcode with the renderer object

我在控制器中写了下面的代码

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

访问条码操作时 -- 条码图像不显示

下面是我从查看源

得到的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