【问题标题】:How to set sise to Barcode-Coder code128如何将 sise 设置为 Barcode-Coder code128
【发布时间】:2014-01-17 11:57:43
【问题描述】:

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

我目前使用的代码

$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 那样简单。我认为这只是条之间的间距,而不是条本身。

非常感谢任何帮助。

【问题讨论】:

    标签: php barcode


    【解决方案1】:

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

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

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

    $高度 = 3; $宽度 = 0.25;

    浏览该页面取决于您的打印机运行的 DPI ......

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-11-06
        • 1970-01-01
        • 2014-06-03
        • 2015-02-01
        • 1970-01-01
        相关资源
        最近更新 更多