Skip to content

Instantly share code, notes, and snippets.

Created April 22, 2015 01:05
Show Gist options
  • Save anonymous/34d234a10a68e7e6936a to your computer and use it in GitHub Desktop.
Save anonymous/34d234a10a68e7e6936a to your computer and use it in GitHub Desktop.
Barcode Gen
<?php
require_once('barcodegen.1d-php5.v5.2.1/class/BCGFontFile.php');
require_once('barcodegen.1d-php5.v5.2.1/class/BCGColor.php');
require_once('barcodegen.1d-php5.v5.2.1/class/BCGDrawing.php');
require_once('barcodegen.1d-php5.v5.2.1/class/BCGcode39.barcode.php');
$font = new BCGFontFile('./barcodegen.1d-php5.v5.2.1/font/Arial.ttf', 18);
$color_black = new BCGColor(0, 0, 0);
$color_white = new BCGColor(255, 255, 255);
// Barcode Part
$code = new BCGcode39();
$code->setScale(2);
$code->setThickness(30);
$code->setForegroundColor($color_black);
$code->setBackgroundColor($color_white);
$code->setFont($font);
$code->setChecksum(false);
$code->parse('A123');
// Drawing Part
$drawing = new BCGDrawing('', $color_white);
$drawing->setBarcode($code);
$drawing->draw();
header('Content-Type: image/png');
$drawing->finish(BCGDrawing::IMG_FORMAT_PNG);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment