2014-01-17 48 views
0

我使用PHP類條碼編碼器(http://barcode-coder.com)生成code128條碼作爲GIF。它工作正常,掃描儀可以讀取它。但是,我想要打印條形碼的區域對於圖像來說很小,如果我只是按比例縮小圖像,則掃描失敗(邏輯上)。有沒有一種方法來設置條的寬度,目前看起來像是使用了兩個像素,這使得它在打印區域變寬。 在示例/ docs中有一個在線生成器,用於生成更細的條形碼的barcorde,但我無法找到此設置。如何設置尺碼爲條碼編碼器code128

我目前使用

$code  = isset($_GET["message"]) ? $_GET["message"] : ""; 

// Settings for barcode 
$marge = 0; // between barcode and hri in pixel 
$x  = 100; // barcode center 
$y  = 15; // barcode center 
$height = 30; // barcode height in 1D ; module size in 2D 
$width = 2; // barcode height in 1D ; not use in 2D 
$angle = 0; // rotation in degrees : nb : non horizontable barcode might not be usable because of pixelisation 
$type  = 'code128'; 

// ALLOCATE GD RESSOURCE 
$im  = imagecreatetruecolor(200, 30); 
$black = ImageColorAllocate($im,0x00,0x00,0x00); 
$white = ImageColorAllocate($im,0xff,0xff,0xff); 
imagefilledrectangle($im, 0, 0, 200, 30, $white); 

// Create barcode 
$data = Barcode::gd($im, $black, $x, $y, $angle, $type, array('code'=>$code), $width, $height); 

// Generate image with barcode 
header('Content-type: image/gif'); 
imagegif($im); 
imagedestroy($im); 

沒有,遺憾的是它並不像從2到1只設置$寬度一樣簡單的代碼,僅僅是吧,不是吧itselfs之間的間距, 我認爲。

任何幫助,非常感謝。

回答

1

您正在尋找的是允許您更改X尺寸或密爾寬度的設置。 X尺寸是條形碼中最窄元素(條或空間)的寬度,單位爲千分之一英寸。我快速地看了一下,它看起來並不像庫允許你指定那個設置,但應該有其他的庫,因爲這是一個非常常見的事情來支持。