Warning: This post is for the ultra technogeek. It is our (small) contribution back to the open source community, which has provided Treasure Coast Film with so much!
With all of the documents we process in a day’s time it is an absolute necessity that we find ways to efficiently manage document processing. Order Forms, reviews, surveys, payment vouchers, estimate authorizations, and other forms would take an indefinitely long time to handle if we didn’t use bar-codes. In another post we will discuss how we decode the bar-codes.
For generating the bar-codes we use the PEAR class of PHP named Image_Barcode2, which lacks good documentation. Here is our attempt to show how to use the class.
If you need to install the class:
pear install Image_Barcode2 (from the linux command line)
Code (which we rotate the image 90 degrees and place it toward the lower right hand bottom of the image.
<?php
function str2barcodeBase64($str) {
include_once “Image/Barcode2.php”;
$str = empty($str) ? ‘test’ : $str;
$type = ‘code128’; //See more below
$imgtype = ‘png’;
$bSendToBrowser = FALSE;
$height = 20;
$width = 1;
$img = Image_Barcode2::draw($str, $type, $imgtype, $bSendToBrowser, $height, $
ob_start();
imagepng($img);
$imgBase64 = base64_encode(ob_get_contents());
ob_end_clean();
imagedestroy($img);
$return = ‘<img src=”data:image/’ . $imgtype . ‘;base64,’ . $imgBase64 . ‘”>’;
return $return;
}
$str = “member1001000”;
$str = “pink0125”;
print “<div style=\”float:right; margin-top: 450px; -webkit-transform:rotate(90deg);width:20px\”>\n”;
print str2barcodeBase64($str);
print “</div>\n”;
?>
Above you will see the variable $types. you can change it to any of these:
Barcode Types:
int25
ean13
ean8
Code39
upca
upce
code128
postnet