Jam*_*mes 2 php zend-framework barcode magento
我第一次使用 Zend_Barcode 框架在 Magento 中生成条形码,目的是将运输条形码添加到发票中。
该模型看起来相当简单,但我无法更改条形码的大小。
如果我起诉这种方法:
$barcodeOptions = array('text' => 'ZEND-FRAMEWORK', 'width'=>400);
$rendererOptions = array('width'=> 400);
$renderer = Zend_Barcode::factory(
'code128', 'image', $barcodeOptions, $rendererOptions
)->render();
Run Code Online (Sandbox Code Playgroud)
我最终得到了一个 275 像素的条码,但一个 400 像素宽的图像。即实际可见条码大小与未发送选项相同,但实际图像大小为 400 像素。
如果我使用 draw 方法也一样。
$barcodeOptions = array('text' => $barCodeNo, 'width'=> '400', 'height'=> '500');
$rendererOptions = array('width'=> '400', 'height'=> '500');
// Draw the barcode in a new image,
$imageResource = Zend_Barcode::draw(
'code128', 'image', $barcodeOptions, $rendererOptions
);
imagejpeg($imageResource);
Run Code Online (Sandbox Code Playgroud)
除了将大小高度和宽度添加到选项数组中之外,我在文档中找不到任何东西,那么我错过了什么?
任何帮助,将不胜感激。
终于明白了:
$barcodeOptions = array(
'text' => $barCodeNo,
'barHeight'=> 74,
'factor'=>3.98,
);
$rendererOptions = array();
$renderer = Zend_Barcode::factory(
'code128', 'image', $barcodeOptions, $rendererOptions
)->render();
Run Code Online (Sandbox Code Playgroud)
'barHeight' 设置条码的高度。
“因子”是增加条码相对大小的索引。3.98 = ~75mm 这正是我所需要的。