문제

I´m using PHP class Barcode-Coder (http://barcode-coder.com) to generate a code128 barcode as a GIF. It works fine and the scanner can read it. However the area where I want to print the barcode is to small for the image and if I just scale the image down the scan fails (logically). Is there a way to set the width of the bars, currently is seems like it uses two pixels and that makes it to wide for my print area. In the example/docs there is a online genereator that generates a barcorde with thinner bars but I can´t find the setting for this.

The code I'm currently using

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

And no, sadly it is not as simple as just setting $width from 2 to 1. That is just the spacing between the bars, not the bars itselfs, i think.

Any help is much appreciated.

도움이 되었습니까?

해결책

I have had this problem aswell .. to solve it.

I used the settings from http://www.idautomation.com/kb/print-quality.html

in my case you had to divide the "width" by 4

$height = 3; $width = 0.25;

going by that page its dependent on what DPI your printer is running at ........

다른 팁

What you are looking for is a setting that allows you to change the X dimension or mil width. The X dimension is the width, in thousandths of an inch, of the narrowest element (bar or space) in a barcode. I took a quick look and it doesn't look like that library allows you to specify that setting but there should be other libraries that do because that is a very common thing to support.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top