53 lines
1.4 KiB
PHP
53 lines
1.4 KiB
PHP
<?php
|
|
include_once ("../../include/mcglobal.inc.php");
|
|
|
|
// Check HTTP-Parameters
|
|
getSecHttpVars("1",array("text"));
|
|
|
|
require 'autoload.php';
|
|
|
|
use BarcodeBakery\Common\BCGColor;
|
|
use BarcodeBakery\Common\BCGDrawing;
|
|
use BarcodeBakery\Common\BCGFontFile;
|
|
use BarcodeBakery\Barcode\BCGcode39;
|
|
|
|
|
|
// Loading Font
|
|
$font = new BCGFontFile('Arial.ttf', 18);
|
|
|
|
// The arguments are R, G, B for color.
|
|
$colorBlack = new BCGColor(0, 0, 0);
|
|
$colorWhite = new BCGColor(255, 255, 255);
|
|
|
|
$drawException = null;
|
|
$barcode = null;
|
|
try {
|
|
$code = new BCGcode39();
|
|
|
|
// Uncomment when using the commercial version
|
|
////$code->useCommercialVersion();
|
|
|
|
$code->setScale(2); // Resolution
|
|
$code->setThickness(30); // Thickness
|
|
$code->setForegroundColor($colorBlack); // Color of bars
|
|
$code->setBackgroundColor($colorWhite); // Color of spaces
|
|
$code->setFont($font); // Font (or 0)
|
|
$code->setChecksum(false);
|
|
$code->parse($text); // Text
|
|
$barcode = $code;
|
|
} catch (Exception $exception) {
|
|
$drawException = $exception;
|
|
}
|
|
|
|
$drawing = new BCGDrawing($barcode, $colorWhite);
|
|
if ($drawException) {
|
|
$drawing->drawException($drawException);
|
|
}
|
|
|
|
// 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);
|