本文实例讲述了php实现生成code128条形码的方法。分享给大家供大家参考,具体如下:
效果图:
<"212222","222122","222221","121223","121322","131222","122213","122312","132212","221213","221312","231212","112232","122132","122231","113222","123122","123221","223211","221132","221231","213212","223112","312131","311222","321122","321221","312212","322112","322211","212123","212321","232121","111323","131123","131321","112313","132113","132311","211313","231113","231311","112133","112331","132131","113123","113321","133121","313121","211331","231131","213113","213311","213131","311123","311321","331121","312113","312311","332111","314111","221411","431111","111224","111422","121124","121421","141122","141221","112214","112412","122114","122411","142112","142211","241211","221114","413111","241112","134111","111242","121142","121241","114212","124112","124211","411212","421112","421211","212141","214121","412121","111143","111341","131141","114113","114311","411113","411311","113141","114131","311141","411131","211412","211214","211412","2331112"); private $valid_code = -1; private $type ='B'; private $start_codes =array('A'=>self::STARTA,'B'=>self::STARTB,'C'=>self::STARTC); private $code =''; private $bin_code =''; private $text =''; public function __construct($code='',$text='',$type='B') { if (in_array($type,array('A','B','C'))) $this->setType($type); else $this->setType('B'); if ($code !=='') $this->setCode($code); if ($text !=='') $this->setText($text); } public function setUnitWidth($unit_width) { $this->unit_width = $unit_width; $this->quiet_zone = $this->unit_width*6; $this->font_height = $this->unit_width*15; if (!$this->is_set_height) { $this->heith = $this->unit_width*35; } } public function setFontType($font_type) { $this->font_type = $font_type; } public function setBgcolor($bgcoloe) { $this->bgcolor = $bgcoloe; } public function setColor($color) { $this->color = $color; } public function setCode($code) { if ($code !='') { $this->code= $code; if ($this->text ==='') $this->text = $code; } } public function setText($text) { $this->text = $text; } public function setType($type) { $this->type = $type; } public function setHeight($height) { $this->height = $height; $this->is_set_height = true; } private function getValueFromChar($ch) { $val = ord($ch); try { if ($this->type =='A') { if ($val > 95) throw new Exception(' illegal barcode character '.$ch.' for code128A in '.__FILE__.' on line '.__LINE__); if ($val < 32) $val += 64; else $val -=32; } elseif ($this->type =='B') { if ($val < 32 || $val > 127) throw new Exception(' illegal barcode character '.$ch.' for code128B in '.__FILE__.' on line '.__LINE__); else $val -=32; } else { if (!is_numeric($ch) || (int)$ch < 0 || (int)($ch) > 99) throw new Exception(' illegal barcode character '.$ch.' for code128C in '.__FILE__.' on line '.__LINE__); else { if (strlen($ch) ==1) $ch .='0'; $val = (int)($ch); } } } catch(Exception $ex) { errorlog('die',$ex->getMessage()); } return $val; } private function parseCode() { $this->type=='C'"Content-Type: image/".$image_type); } switch ($image_type) { case 'jpg': case 'jpeg': Imagejpeg($this->image,$file_name); break; case 'png': Imagepng($this->image,$file_name); break; case 'gif': break; Imagegif($this->image,$file_name); default: Imagepng($this->image,$file_name); break; } } } $barcode = new BarCode128('88888888'); $barcode->createBarCode(); "_blank" href="http://www.barcodebakery.com/" rel="external nofollow" >http://www.barcodebakery.com/PS:这里再为大家推荐一款相似的条形码生成工具供大家参考使用:
在线条形码(一维码)生成/实时预览工具:
http://tools.jb51.net/aideddesign/tiaoxingma更多关于PHP相关内容感兴趣的读者可查看本站专题:《PHP图形与图片操作技巧汇总》、《PHP数组(Array)操作技巧大全》、《PHP数据结构与算法教程》、《php程序设计算法总结》、《PHP数学运算技巧总结》、《php字符串(string)用法总结》及《php常见数据库操作技巧汇总》
希望本文所述对大家PHP程序设计有所帮助。
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
暂无评论...
P70系列延期,华为新旗舰将在下月发布
3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。
而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?
根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。
更新日志
2024年11月28日
2024年11月28日
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]