免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 6910 | 回复: 16

请教: PHP+MYSQL如何生成条形码? [复制链接]

论坛徽章:
0
发表于 2004-10-21 04:24 |显示全部楼层
我是新手, Server是PHP+MYSQL+LINUX, Client是windows, 需要生成条形码, 打印机连在windows上, 向高手请教, 该如何处理? My email: cssa2ca@yahoo.com. 非常感谢.

论坛徽章:
0
发表于 2004-10-21 09:26 |显示全部楼层

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

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

论坛徽章:
0
发表于 2004-10-21 09:31 |显示全部楼层

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

up,找到了show出来哦

论坛徽章:
0
发表于 2004-10-21 10:15 |显示全部楼层

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

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



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

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
发表于 2004-10-21 10:31 |显示全部楼层

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

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

找不到了联系我

论坛徽章:
0
发表于 2004-10-21 10:46 |显示全部楼层

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

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

找不到了联系我


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

论坛徽章:
0
发表于 2004-10-21 11:50 |显示全部楼层

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

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

论坛徽章:
0
发表于 2004-10-21 11:55 |显示全部楼层

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

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

  51. UPCAbarcode('12345678901');

  52. ?>;
复制代码

论坛徽章:
0
发表于 2004-10-21 12:01 |显示全部楼层

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

这个标准我也找到过

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
发表于 2004-10-21 12:18 |显示全部楼层

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

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

其实,你就是要获得条形码的那些字符的规范,多宽多长怎么组合就可以的阿
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP