xiao xue 发表于 2004-10-21 04:24

请教: PHP+MYSQL如何生成条形码?

我是新手, Server是PHP+MYSQL+LINUX, Client是windows, 需要生成条形码, 打印机连在windows上, 向高手请教, 该如何处理? My email: cssa2ca@yahoo.com. 非常感谢.

laokan 发表于 2004-10-21 09:26

请教: PHP+MYSQL如何生成条形码?

你可以研究一下条码的生成标准,自己用gd按照标准画. 一般商品上的都是13位的,还有是8位的,我在网上找到过php的例子的,你可以找找,
着个标准网上也能找的到,找不到了联系我!

xmlv 发表于 2004-10-21 09:31

请教: PHP+MYSQL如何生成条形码?

up,找到了show出来哦

xiao xue 发表于 2004-10-21 10:15

请教: PHP+MYSQL如何生成条形码?

原帖由 "laokan" 发表:
你可以研究一下条码的生成标准,自己用gd按照标准画. 一般商品上的都是13位的,还有是8位的,我在网上找到过php的例子的,你可以找找,
着个标准网上也能找的到,找不到了联系我!


我已经google了 2天了. 还是不知道如何下手.请问如何联系您? 谢谢.

HonestQiao 发表于 2004-10-21 10:31

请教: PHP+MYSQL如何生成条形码?

你看看你的条形码标准是那个地方颁发的,你找颁发机构要标准阿

找不到了联系我

xiao xue 发表于 2004-10-21 10:46

请教: PHP+MYSQL如何生成条形码?

原帖由 "HonestQiao" 发表:
你看看你的条形码标准是那个地方颁发的,你找颁发机构要标准阿

找不到了联系我

其实我只要打印一张工单, 上面有10-13位数字的, 能用bar code reader识别出来就可以了. 需要什么标准吗? 谢谢!

abin30 发表于 2004-10-21 11:50

请教: PHP+MYSQL如何生成条形码?

我们直接用条形码字体,还没有测试过能不能识别

laokan 发表于 2004-10-21 11:55

请教: PHP+MYSQL如何生成条形码?

你可以看看下面的代码,可能要gd支持的!!
<?
function UPCAbarcode($code) {
$lw = 2; $hi = 100;
$Lencode = array('0001101','0011001','0010011','0111101','0100011',
                   '0110001','0101111','0111011','0110111','0001011');
$Rencode = array('1110010','1100110','1101100','1000010','1011100',
                   '1001110','1010000','1000100','1001000','1110100');
$ends = '101'; $center = '01010';
/* UPC-A Must be 11 digits, we compute the checksum. */
if ( strlen($code) != 11 ) { die("UPC-A Must be 11 digits."); }
/* Compute the EAN-13 Checksum digit */
$ncode = '0'.$code;
$even = 0; $odd = 0;
for ($x=0;$x<12;$x++) {
    if ($x % 2) { $odd += $ncode[$x]; } else { $even += $ncode[$x]; }
}
$code.=(10 - (($odd * 3 + $even) % 10)) % 10;
/* Create the bar encoding using a binary string */
$bars=$ends;
$bars.=$Lencode[$code];
for($x=1;$x<6;$x++) {
    $bars.=$Lencode[$code[$x]];
}
$bars.=$center;
for($x=6;$x<12;$x++) {
    $bars.=$Rencode[$code[$x]];
}
$bars.=$ends;
/* Generate the Barcode Image */
$img = ImageCreate($lw*95+30,$hi+30);
$fg = ImageColorAllocate($img, 0, 0, 0);
$bg = ImageColorAllocate($img, 255, 255, 255);
ImageFilledRectangle($img, 0, 0, $lw*95+30, $hi+30, $bg);
$shift=10;
for ($x=0;$x<strlen($bars);$x++) {
    if (($x<10) || ($x>;=45 && $x<50) || ($x >;=85)) { $sh=10; } else { $sh=0; }
    if ($bars[$x] == '1') { $color = $fg; } else { $color = $bg; }
    ImageFilledRectangle($img, ($x*$lw)+15,5,($x+1)*$lw+14,$hi+5+$sh,$color);
}
/* Add the Human Readable Label */
ImageString($img,4,5,$hi-5,$code,$fg);
for ($x=0;$x<5;$x++) {
    ImageString($img,5,$lw*(13+$x*6)+15,$hi+5,$code[$x+1],$fg);
    ImageString($img,5,$lw*(53+$x*6)+15,$hi+5,$code[$x+6],$fg);
}
ImageString($img,4,$lw*95+17,$hi-5,$code,$fg);
/* Output the Header and Content. */
header("Content-Type: image/png");
ImagePNG($img);
}

UPCAbarcode('12345678901');

?>;

laokan 发表于 2004-10-21 12:01

请教: PHP+MYSQL如何生成条形码?

这个标准我也找到过

HonestQiao 发表于 2004-10-21 12:18

请教: PHP+MYSQL如何生成条形码?

用PNG来生成,不要gd支持照样可以的。

其实,你就是要获得条形码的那些字符的规范,多宽多长怎么组合就可以的阿
页: [1] 2
查看完整版本: 请教: PHP+MYSQL如何生成条形码?