function draw($text = "1111111111111")
 {
     $_GET = array('code' => "BCGcode128", 'filetype' => "PNG", 'dpi' => 72, 'scale' => 1, 'rotation' => 0, 'font_family' => "Arial.ttf", 'font_size' => 8, 'text' => $text, 'thickness' => 30);
     $filetypes = array('PNG' => BCGDrawing::IMG_FORMAT_PNG, 'JPEG' => BCGDrawing::IMG_FORMAT_JPEG, 'GIF' => BCGDrawing::IMG_FORMAT_GIF);
     $drawException = null;
     try {
         $color_black = new BCGColor(0, 0, 0);
         $color_white = new BCGColor(255, 255, 255);
         $code_generated = new BCGcode128();
         if (function_exists('baseCustomSetup')) {
             baseCustomSetup($code_generated, $_GET);
         }
         if (function_exists('customSetup')) {
             customSetup($code_generated, $_GET);
         }
         $code_generated->setScale(max(1, min(4, $_GET['scale'])));
         $code_generated->setBackgroundColor($color_white);
         $code_generated->setForegroundColor($color_black);
         if ($_GET['text'] !== '') {
             $text = convertText($_GET['text']);
             $code_generated->parse($text);
         }
     } catch (Exception $exception) {
         $drawException = $exception;
     }
     $drawing = new BCGDrawing('', $color_white);
     if ($drawException) {
         $drawing->drawException($drawException);
     } else {
         $drawing->setBarcode($code_generated);
         $drawing->setRotationAngle($_GET['rotation']);
         $drawing->setDPI($_GET['dpi'] === 'NULL' ? null : max(72, min(300, intval($_GET['dpi']))));
         $drawing->draw();
     }
     switch ($_GET['filetype']) {
         case 'PNG':
             header('Content-Type: image/png');
             break;
         case 'JPEG':
             header('Content-Type: image/jpeg');
             break;
         case 'GIF':
             header('Content-Type: image/gif');
             break;
     }
     $drawing->finish($filetypes[$_GET['filetype']]);
 }
Beispiel #2
0
 public function run()
 {
     /*        $className = 'BCGcodabar';
             $baseClassFile = 'BCGBarcode1D.php';
             $codeVersion = '5.0.2';*/
     $color_black = new \BCGColor(0, 0, 0);
     $color_white = new \BCGColor(255, 255, 255);
     $filetypes = array('PNG' => \BCGDrawing::IMG_FORMAT_PNG, 'JPEG' => \BCGDrawing::IMG_FORMAT_JPEG, 'GIF' => \BCGDrawing::IMG_FORMAT_GIF);
     $code_generated = new \BCGcode128();
     $this->baseCustomSetup($code_generated);
     $code_generated->setScale(max(1, min(4, 4)));
     $code_generated->setBackgroundColor($color_white);
     $code_generated->setForegroundColor($color_black);
     $code_generated->parse($this->message);
     $drawing = new \BCGDrawing('', $color_white);
     $drawing->setBarcode($code_generated);
     $drawing->setRotationAngle(0);
     $drawing->setDPI(72);
     $drawing->draw();
     header('Content-Type: image/png');
     $drawing->finish($filetypes['PNG']);
     return "Hello!";
 }
Beispiel #3
0
    }
    $code_generated->setScale(max(1, min(4, $_GET['scale'])));
    $code_generated->setBackgroundColor($color_white);
    $code_generated->setForegroundColor($color_black);
    if ($_GET['text'] !== '') {
        $code_generated->parse($_GET['text']);
    }
} catch (Exception $exception) {
    $drawException = $exception;
}
$drawing = new BCGDrawing('', $color_white);
if ($drawException) {
    $drawing->drawException($drawException);
} else {
    $drawing->setBarcode($code_generated);
    $drawing->setRotationAngle($_GET['rotation']);
    $drawing->setDPI($_GET['dpi'] === 'NULL' ? null : max(72, min(300, intval($_GET['dpi']))));
    $drawing->draw();
}
switch ($_GET['filetype']) {
    case 'PNG':
        header('Content-Type: image/png');
        break;
    case 'JPEG':
        header('Content-Type: image/jpeg');
        break;
    case 'GIF':
        header('Content-Type: image/gf');
        break;
}
$drawing->finish($filetypes[$_GET['filetype']]);
Beispiel #4
0
function barcode($code)
{
    if (!isset($_GET['filetype'])) {
        $_GET['filetype'] = 'PNG';
    }
    if (!isset($_GET['dpi'])) {
        $_GET['dpi'] = '72';
    }
    if (!isset($_GET['thickness'])) {
        $_GET['thickness'] = '30';
    }
    if (!isset($_GET['scale'])) {
        $_GET['scale'] = '1';
    }
    if (!isset($_GET['rotation'])) {
        $_GET['rotation'] = '0';
    }
    if (!isset($_GET['font_family'])) {
        $_GET['font_family'] = 'Arial.ttf';
    }
    if (!isset($_GET['font_size'])) {
        $_GET['font_size'] = '8';
    }
    if (!isset($_GET['setChecksum'])) {
        $_GET['setChecksum'] = '0';
    }
    if (!isset($_GET['code'])) {
        $_GET['code'] = 'BCGcode39';
    }
    $_GET['text'] = $code;
    $requiredKeys = array('code', 'filetype', 'dpi', 'thickness', 'scale', 'rotation', 'font_family', 'font_size', 'text');
    $possibleCodes = array('BCGcodabar', 'BCGcode11', 'BCGcode39', 'BCGcode39extended', 'BCGcode93', 'BCGcode128', 'BCGean8', 'BCGean13', 'BCGgs1128', 'BCGi25', 'BCGisbn', 'BCGmsi', 'BCGs25', 'BCGupca', 'BCGupce', 'BCGupcext2', 'BCGupcext5', 'BCGothercode', 'BCGpostnet', 'BCGintelligentmail');
    // Check if everything is present in the request
    foreach ($requiredKeys as $key) {
        if (!isset($_GET[$key])) {
            showError();
        }
    }
    // Check if the code is valid
    if (!in_array($_GET['code'], $possibleCodes)) {
        showError();
    }
    $class_dir = 'class';
    require_once $class_dir . DIRECTORY_SEPARATOR . 'BCGColor.php';
    require_once $class_dir . DIRECTORY_SEPARATOR . 'BCGBarcode.php';
    require_once $class_dir . DIRECTORY_SEPARATOR . 'BCGDrawing.php';
    require_once $class_dir . DIRECTORY_SEPARATOR . 'BCGFontFile.php';
    if (!(include_once $class_dir . DIRECTORY_SEPARATOR . $_GET['code'] . '.barcode.php')) {
        showError();
    }
    $barcodeSupports = array('setChecksum' => array('BCGcode39', 'BCGcode39extended', 'BCGi25', 'BCGs25', 'BCGmsi'), 'setStart' => array('BCGcode128', 'BCGgs1128'), 'barcodeIdentifier' => array('BCGintelligentmail'), 'setLabel' => array('BCGothercode'));
    $filetypes = array('PNG' => BCGDrawing::IMG_FORMAT_PNG, 'JPEG' => BCGDrawing::IMG_FORMAT_JPEG, 'GIF' => BCGDrawing::IMG_FORMAT_GIF);
    $drawException = null;
    try {
        $color_black = new BCGColor(0, 0, 0);
        $color_white = new BCGColor(255, 255, 255);
        $font = 0;
        if ($_GET['font_family'] !== '0' && intval($_GET['font_size']) >= 1) {
            $font = new BCGFontFile(APPPATH . '/helpers/' . $class_dir . '/font/' . $_GET['font_family'], intval($_GET['font_size']));
        }
        $code_generated = new $_GET['code']();
        // Since image.php supports all barcode, we must check here
        // Which one support which option
        foreach ($barcodeSupports as $option => $barcodeNames) {
            if (isset($_GET[$option])) {
                if (in_array($_GET['code'], $barcodeNames)) {
                    $value = $_GET[$option];
                    switch ($value) {
                        case 'true':
                            $value = true;
                            break;
                        case 'false':
                            $value = false;
                            break;
                        case 'NULL':
                            $value = null;
                            break;
                        default:
                            if (is_numeric($value)) {
                                // We accept only integer...
                                $value = intval($value);
                            }
                    }
                    switch ($option) {
                        case 'setChecksum':
                        case 'setStart':
                        case 'setLabel':
                            $code_generated->{$option}($value);
                            break;
                        case 'barcodeIdentifier':
                            // Make sure we have all we need
                            if (!isset($_GET['serviceType']) || !isset($_GET['mailerIdentifier']) || !isset($_GET['serialNumber'])) {
                                break;
                            }
                            $code_generated->setTrackingCode(intval($_GET['barcodeIdentifier']), intval($_GET['serviceType']), intval($_GET['mailerIdentifier']), intval($_GET['serialNumber']));
                            break;
                    }
                }
            }
        }
        $code_generated->setThickness($_GET['thickness']);
        $code_generated->setScale($_GET['scale']);
        $code_generated->setBackgroundColor($color_white);
        $code_generated->setForegroundColor($color_black);
        $code_generated->setFont($font);
        $code_generated->parse($_GET['text']);
    } catch (Exception $exception) {
        $drawException = $exception;
    }
    $drawing = new BCGDrawing('', $color_white);
    if ($drawException) {
        $drawing->drawException($drawException);
    } else {
        $drawing->setBarcode($code_generated);
        $drawing->setRotationAngle($_GET['rotation']);
        $drawing->setDPI($_GET['dpi'] === 'NULL' ? null : intval($_GET['dpi']));
        $drawing->draw();
    }
    switch ($_GET['filetype']) {
        case 'PNG':
            header('Content-Type: image/png');
            break;
        case 'JPEG':
            header('Content-Type: image/jpeg');
            break;
        case 'GIF':
            header('Content-Type: image/gif');
            break;
    }
    $drawing->finish($filetypes[$_GET['filetype']]);
}
 public function code128($kdnr, $vorname, $nachname, $gender)
 {
     $barcode = 'S' . $kdnr;
     $oo = 1;
     $pruefziffer = $this->pruefen($kdnr);
     $label = $kdnr . ' ' . $pruefziffer;
     $f1 = 'Arial.ttf';
     $f2 = 8;
     $a1 = '';
     $a2 = NULL;
     $a3 = '';
     $t = 50;
     $r = 1;
     if ($f1 !== '0' && $f1 !== '-1' && intval($f2) >= 1) {
         //$font = new BCGFontFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('woehrl_stylecardantrag') . '/Classes/Barcode/Font'. $f1, intval($f2));
         $font = new \BCGFontFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('woehrl_stylecardantrag') . 'Classes/Barcode/Font/' . $f1, intval($f2));
     } else {
         $font = 0;
     }
     $color_black = new \BCGColor(0, 0, 0);
     $color_white = new \BCGColor(255, 255, 255);
     $codebar = 'BCGcode128';
     $drawException = null;
     try {
         $code_generated = new $codebar();
         if (isset($a1) && intval($a1) === 1) {
             $code_generated->setChecksum(true);
         }
         if (isset($a2) && !empty($a2)) {
             $code_generated->setStart($a2 === 'NULL' ? null : $a2);
         }
         if (isset($a3) && !empty($a3)) {
             $code_generated->setLabel($a3 === 'NULL' ? null : $a3);
         }
         $code_generated->setThickness($t);
         $code_generated->setScale($r);
         $code_generated->setBackgroundColor($color_white);
         $code_generated->setForegroundColor($color_black);
         $code_generated->setFont($font);
         $code_generated->setLabel($label);
         $code_generated->parse($barcode);
     } catch (Exception $exception) {
         $drawException = $exception;
     }
     $drawing = new \BCGDrawing('./uploads/tx_woehrlstylecardantrag/' . $kdnr . '.png', $color_white);
     if ($drawException) {
         $drawing->drawException($drawException);
     } else {
         $drawing->setBarcode($code_generated);
         $drawing->setRotationAngle('0');
         $drawing->setDPI('72');
         $drawing->draw();
     }
     $drawing->finish(intval($oo));
     $image1 = imageCreateFromjpeg("./typo3conf/ext/woehrl_stylecardantrag/Resources/Public/Images/Woehrl-stylecard-Kundenkarte.jpg");
     $image2 = imageCreateFromPNG('./uploads/tx_woehrlstylecardantrag/' . $kdnr . '.png');
     imageCopy($image1, $image2, 28, 125, 0, 0, 123, 62);
     $color = ImageColorAllocate($image1, 255, 255, 255);
     $font_file = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('woehrl_stylecardantrag') . '/Classes/Barcode/Font/Arial.ttf';
     if (strlen($vorname . ' ' . $nachname) < 24) {
         imagefttext($image1, 11, 0, 25, 70, $color, $font_file, $gender);
         imagefttext($image1, 11, 0, 25, 90, $color, $font_file, $vorname . ' ' . $nachname);
     } else {
         imagefttext($image1, 11, 0, 25, 70, $color, $font_file, $gender);
         imagefttext($image1, 11, 0, 25, 90, $color, $font_file, $nachname);
     }
     imagefttext($image1, 11, 0, 25, 110, $color, $font_file, $kdnr);
     if (imagejpeg($image1, './uploads/tx_woehrlstylecardantrag/stylecard_' . $kdnr . '.jpg', 100)) {
         return './uploads/tx_woehrlstylecardantrag/stylecard_' . $kdnr . '.jpg';
     }
 }
Beispiel #6
0
 /**
  * 条形码
  */
 public function barcode()
 {
     //获取code
     $code = $this->_GSCode();
     //加载基础类库
     require_once VENDOR_PATH . 'Barcodegen/class/BCGColor.php';
     require_once VENDOR_PATH . 'Barcodegen/class/BCGBarcode.php';
     require_once VENDOR_PATH . 'Barcodegen/class/BCGDrawing.php';
     require_once VENDOR_PATH . 'Barcodegen/class/BCGFontFile.php';
     //加载code128类库
     require_once VENDOR_PATH . 'Barcodegen/class/BCGcode128.barcode.php';
     //输出图片格式
     $filetypes = array('PNG' => \BCGDrawing::IMG_FORMAT_PNG, 'JPEG' => \BCGDrawing::IMG_FORMAT_JPEG, 'GIF' => \BCGDrawing::IMG_FORMAT_GIF);
     //配置信息
     $className = 'BCGcode128';
     $codeconfig = array('filetype' => 'PNG', 'dpi' => '72', 'scale' => '3', 'rotation' => '0', 'font_family' => 'Arial.ttf', 'font_size' => '30', 'text' => $code, 'thickness' => '68', 'start' => 'A', 'code' => 'BCGcode128');
     //画图
     $drawException = null;
     try {
         $color_black = new \BCGColor(0, 0, 0);
         $color_white = new \BCGColor(255, 255, 255);
         $code_generated = new $className();
         //设置样式
         if (isset($codeconfig['thickness'])) {
             $code_generated->setThickness(max(9, min(90, intval($codeconfig['thickness']))));
         }
         $font = 0;
         if ($codeconfig['font_family'] !== '0' && intval($codeconfig['font_size']) >= 1) {
             $font = new \BCGFontFile(VENDOR_PATH . 'Barcodegen/font/' . $codeconfig['font_family'], intval($codeconfig['font_size']));
         }
         $code_generated->setFont($font);
         //编码方式A
         if (isset($codeconfig['start'])) {
             $code_generated->setStart($codeconfig['start'] === 'NULL' ? null : $codeconfig['start']);
         }
         $code_generated->setScale(max(1, min(4, $codeconfig['scale'])));
         $code_generated->setBackgroundColor($color_white);
         $code_generated->setForegroundColor($color_black);
         if ($codeconfig['text'] !== '') {
             $code = stripslashes($codeconfig['text']);
             if (function_exists('mb_convert_encoding')) {
                 $code = mb_convert_encoding($code, 'ISO-8859-1', 'UTF-8');
             }
             $code_generated->parse($code);
         }
     } catch (Exception $exception) {
         $drawException = $exception;
     }
     $drawing = new \BCGDrawing('', $color_white);
     if ($drawException) {
         $drawing->drawException($drawException);
     } else {
         $drawing->setBarcode($code_generated);
         $drawing->setRotationAngle($codeconfig['rotation']);
         $drawing->setDPI($codeconfig['dpi'] === 'NULL' ? null : max(72, min(300, intval($codeconfig['dpi']))));
         $drawing->draw();
     }
     switch ($codeconfig['filetype']) {
         case 'PNG':
             header('Content-Type: image/png');
             break;
         case 'JPEG':
             header('Content-Type: image/jpeg');
             break;
         case 'GIF':
             header('Content-Type: image/gif');
             break;
     }
     $drawing->finish($filetypes[$codeconfig['filetype']]);
 }
Beispiel #7
0
	if($a2 && !empty($a2)) {
		$code_generated->setStart($a2);
	}
	if(isset($a3) && !empty($a3)) {
		$code_generated->setLabel($a3);
	}
	$code_generated->setThickness($t);
	$code_generated->setScale($r);
	$code_generated->setBackgroundColor($color_white);
	$code_generated->setForegroundColor($color_black);
	$code_generated->setFont($font);
	$code_generated->parse($text);
	
	$drawing = new BCGDrawing('', $color_white);
	$drawing->setBarcode($code_generated);
	$drawing->setRotationAngle($rot);
	$drawing->setDPI($dpi == 'null' ? null : (int)$dpi);
	$drawing->draw();
	if(intval($o) === 1) {
		header('Content-Type: image/png');
	} elseif(intval($o) === 2) {
		header('Content-Type: image/jpeg');
	} elseif(intval($o) === 3) {
		header('Content-Type: image/gif');
	}
	$drawing->finish(intval($o));
} else {
	header('Content-Type: image/png');
	readfile('error.png');
}
?>