Whilst fiddling around with QR Codes, I came across this Bar-code generator for PHP.
In this post:
- Minimum requirements
- Code
1. Minimum requirements
Your server configuration must comply with the following:
- PHP 5
- GD2 Extension
2. Code
Here is my code for a basic implementation (adapted from the manual which has errors):
<?php require_once('class/BCGFontFile.php'); require_once('class/BCGColor.php'); require_once('class/BCGDrawing.php'); require_once('class/BCGcode128.barcode.php'); // The arguments are R, G, and B for color. $colorBack = new BCGColor(255, 255, 255); $code = new BCGcode128(); // Or another class name from the manual $code->parse('BARCODE'); // Text $image_name = 'mybc.png'; $drawing = new BCGDrawing($image_name, $colorBack); $drawing->setBarcode($code); $drawing->draw(); header('Content-Type: image/png'); $drawing->finish(BCGDrawing::IMG_FORMAT_PNG); echo '<img src="'.$image_name.'" />'; ?>
References:
- Dependable barcode generation software to simplify your business. (no date) Barcode Bakery. Available at: https://www.barcodebakery.com/ (Accessed: 9 March 2024).