Zend 条码图像在 CodeIgniter 中无法正确生成

Zend Barcode image isn't generate correctly in CodeIgniter

提问人:ruhunu 提问时间:11/8/2023 最后编辑:ruhunu 更新时间:11/8/2023 访问量:25

问:

我使用 Zend 条形码库为我的 CodeIgniter 项目中的库存物品生成条形码。并使用以下代码来执行此操作。

public function gen_barcode($product_code = NULL, $bcs = 'code128', $height = 60, $text = 1)
    {
        
        $drawText = ($text != 1) ? FALSE : TRUE;
        $this->load->library('zend');
        $this->zend->load('Zend/Barcode');
        $barcodeOptions = array('text' => $product_code, 'barHeight' => $height, 'drawText' => $drawText, 'factor' => 1.0);
        if (0) {
            $rendererOptions = array('imageType' => 'jpg', 'horizontalPosition' => 'center', 'verticalPosition' => 'middle');
            $imageResource = Zend_Barcode::render($bcs, 'image', $barcodeOptions, $rendererOptions);
            return $imageResource;
            
        } else {
            $rendererOptions = array('renderer' => 'svg', 'horizontalPosition' => 'center', 'verticalPosition' => 'middle');
            $imageResource = Zend_Barcode::render($bcs, 'svg', $barcodeOptions, $rendererOptions);
            header("Content-Type: image/svg+xml");
            echo $imageResource;
        }
    }

但是条形码图像无法正确生成。生成的图像如下:

生成的图像

谁能帮忙?

codeigniter zend-framework

评论


答: 暂无答案