php barcode 制作二條碼,隱藏條碼的內容,只保留條碼


<?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就可以了,若是為此設置字體,那就是顯示條形碼的內容


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM