PHP:使用 Zend_Barcode 调整条形码的输出大小 | Magento 发票条形码

标签 php magento zend-framework barcode

我第一次使用 Zend_Barcode 框架在 Magento 中生成条形码,目的是将运输条形码添加到发票中。

模型看起来相当简单,但我无法更改条形码的大小。

如果我起诉这个方法:

$barcodeOptions = array('text' => 'ZEND-FRAMEWORK', 'width'=>400);
$rendererOptions = array('width'=> 400);
$renderer = Zend_Barcode::factory(
    'code128', 'image', $barcodeOptions, $rendererOptions
)->render();

我最终得到的条形码是 275 像素,但图像是 400 像素宽。即实际可见条形码的大小与未发送选项时的大小相同,但实际图像大小为 400px。

如果我使用绘制方法也是如此。

$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);

除了将尺寸高度和宽度添加到选项数组中之外,我在文档中找不到任何内容,那么我缺少什么?

如有任何帮助,我们将不胜感激。

最佳答案

终于明白了:

$barcodeOptions = array(
    'text' => $barCodeNo, 
    'barHeight'=> 74, 
    'factor'=>3.98,
);


$rendererOptions = array();
$renderer = Zend_Barcode::factory(
    'code128', 'image', $barcodeOptions, $rendererOptions
)->render();

'barHeight' 设置条形码的高度。
“因子”是增加条形码相对大小的索引。 3.98 = ~75mm,这就是我所需要的。

关于PHP:使用 Zend_Barcode 调整条形码的输出大小 | Magento 发票条形码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15804657/

相关文章:

javascript - Magento 定制产品设计

magento - PayPal 拒绝付款请求并在 Magento 中给出货币错误

security - Zend 和 Yii Framework 应用程序之间的单点登录

php - 从多个 PHP 数组创建 JSON

php - 如何简化sql查询

Magento 1.6.1 - 从购物车中删除重定向到主页(运行 Varnish)

php - 原则 2 - 在用户未登录的情况下更新用户密码

zend-framework - Zend 框架与 Google Chart

php - 使用 jQuery 在 XML 中组织数据

php - Laravel Response::json() 带数字检查