2

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 です。

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

オプション配列にサイズの高さと幅を追加する以外に、ドキュメントには何も見つかりません。何が欠けていますか?

どんな助けでも大歓迎です。

4

1 に答える 1

5

Finally got it:

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


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

'barHeight' sets the height of the barcode.
'factor' is an index that increases the size of the barcode relative. 3.98 = ~75mm which is what I needed.

于 2013-04-04T11:05:39.340 に答える