2014-01-17 47 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尺寸是条形码中最窄元素(条或空间)的宽度,单位为千分之一英寸。我快速地看了一下,它看起来并不像库允许你指定那个设置,但应该有其他的库,因为这是一个非常常见的事情来支持。