PHP gen Barcode ตัวอย่างโปรแกรม Gen Barcode Images ด้วย PHP
ตัวอย่าง function ที่ผมใช้นะครับ
public function genBarCode($code_id){
$text = $code_id;
$font_size = 50;
$height = 80;
$width = 100;
$im = ImageCreate($width, $height);
$grey = ImageColorAllocate($im, 230, 230, 230);
$black = ImageColorAllocate($im, 0, 0, 0);
$text_bbox = ImageTTFBBox($font_size, 0, "font/FRE3OF9X.TTF", $text);
$image_centerx = $width / 2;
$image_centery = $height / 2;
$text_x = $image_centerx - round(($text_bbox[4]/2));
$text_y = $image_centery;
ImageTTFText($im, $font_size, 0, $text_x, $text_y, $black, "font/FRE3OF9X.TTF", $text);
ImagePng($im,"barcode/bc_$code_id.png");
ImageDestroy ($im);
}
ก่อนอื่นต้องหา download bar code font มาก่อนนะครับมีให้ download ฟรีครับ