Bardcodes using PHP Pear Image_Barcode
Management of delegate registration at open source conferences has been an issue for quite some time - the main problem is that usually there are no online payment options and the queue gets very long specially on the first day. Late last year I had an opportunity to deploy something which made me feel "we should have done this years ago!" Using Bar codes on delegate registration cards. This saved us a lot of time on not having to enter the delegate code while distributing delegate kits and also at the food court.
If you want a quick premier on Barcode I suggest you read this. In this post I will quickly outline how Bar codes can put on any image using the Pear class Image_Barcode, the pear page shows it as unmaintained but the class itself does the job pretty well.
Below is a somewhat simplified code for printing the bar code on a delegate card
-
// Get the magic of bar code creation in your script
-
require_once("Image/Barcode.php");
-
-
// Create the barcode object
-
$barcode = new Image_Barcode;
-
-
// Create the barcode image resource using the draw method
-
// The first param is the string you want to code into the bars
-
$barCodeImg = $bc->draw("587e0838", "Code39", "png", false);
-
-
// Create the ticket image
-
$ticketImg = ImageCreateFromPNG("ticket.png");
-
-
// Put in code to write whatever you want on the ticket image here
-
// eg: The delegate's name and organisation etc
-
-
// Merge the Bar code image with the ticket image
-
imagecopymerge($ticketImg, $barCodeImg, 20, 140, 0, 0, 160, 50, 75);
-
-
// Send proper headers
-
-
// Send the image data
-
imagepng($img);
-
imagedestroy($img);
If you coded your script properly you will get an output similar to the the one shown below

Reading this bar code is extremely easy as you get bar code readers which simulate USB keyboards. The readers can also be programmed to add a carriage return at the end to simulate the enter key being pressed. So now all you need is a HTML form with just 1 field, a successful scan will submit this form and what you do with it is up to you
About this entry
You’re currently reading “ Bardcodes using PHP Pear Image_Barcode ,” an entry on SANIsoft – PHP for E Biz
- Published:
- 2.1.10 / 1:05pm
- Author:
- Tarique Sani
No comments
Jump to comment form | comments rss | trackback uri