如何将 sise 设置为条形码-编码器代码128



我正在使用PHP类Barcode-Coder(http://barcode-coder.com)生成code128条形码作为GIF。它工作正常,扫描仪可以读取它。但是,我想打印条形码的区域对于图像来说很小,如果我只是缩小图像,扫描就会失败(逻辑上)。有没有办法设置条的宽度,目前似乎它使用两个像素,这使得它为我的打印区域加宽。在示例/文档中,有一个在线生成器,它可以生成一个带有更细条的 barcorde,但我找不到此设置。

我当前使用的代码

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

不,可悲的是,这并不像将$width从 2 设置为 1 那么简单。我认为,这只是条形之间的间距,而不是条形本身。

任何帮助都非常感谢。

我也遇到了这个问题..解决它。

我使用了 http://www.idautomation.com/kb/print-quality.html 中的设置

在我的情况下,您必须将"宽度"除以 4

$height = 3;$width = 0.25;

通过该页面,它取决于您的打印机运行的DPI。

您正在寻找的是一个允许您更改 X 尺寸或密耳宽度的设置。X 维度是条形码中最窄元素(条形或空格)的宽度(以千分之一英寸为单位)。 我快速浏览了一下,看起来该库不允许你指定该设置,但应该有其他库这样做,因为这是非常普遍的事情。

相关内容

最新更新