<?php global $_W, $_GPC; $operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display'; require_once IA_ROOT . '/framework/library/barcode/class/BCGFontFile.php'; require_once IA_ROOT . '/framework/library/barcode/class/BCGColor.php'; require_once IA_ROOT . '/framework/library/barcode/class/BCGDrawing.php'; require_once IA_ROOT . '/framework/library/barcode/class/BCGcode128.barcode.php'; // Loading Font $font = new BCGFontFile( '../framework/library/barcode/font/Arial.ttf', 14); // Don't forget to sanitize user inputs $text = isset($_GPC['text']) ? $_GPC['text'] : 'HELLO'; // The arguments are R, G, B for color. $color_black = new BCGColor(0, 0, 0); $color_white = new BCGColor(255, 255, 255); $drawException = null; try { $code = new BCGcode128(); $code->setScale(2); // Resolution $code->setThickness(40); // Thickness $code->setForegroundColor($color_black); // Color of bars $code->setBackgroundColor($color_white); // Color of spaces $code->setFont(0); // Font (or 0) $code->parse($text); // Text } catch(Exception $exception) { $drawException = $exception; } /* Here is the list of the arguments 1 - Filename (empty : display on screen) 2 - Background color */ $drawing = new BCGDrawing('', $color_white); if($drawException) { $drawing->drawException($drawException); } else { $drawing->setBarcode($code); $drawing->draw(); } // Header that says it is an image (remove it if you save the barcode to a file) header('Content-Type: image/png'); header('Content-Disposition: inline; filename="barcode.png"'); // Draw (or save) the image into PNG format. $drawing->finish(BCGDrawing::IMG_FORMAT_PNG); ?>
将$code->setFont(0); // 设置为0就可以了,若是为此设置字体,那就是显示条形码的内容