[ic] Barcode Tag for creating code128 barcodes

Marty Tennison marty at sediva.com
Sat Nov 4 20:19:56 EST 2006

Here is a tag that creates code128 barcodes.  Enjoy.

UserTag code128 Order label width height border scale font show_text 
font_margin font_align transparent_text top_margin bottom_margin 
left_margin right_margin padding mode
UserTag code128 Interpolate
UserTag code128 Routine <<EOR
sub {

	use Barcode::Code128 'FNC1';

	my($label, $width, $height, $border, $scale, $font, $show_text, 
$font_margin, $font_align, $transparent_text, $top_margin, 
$bottom_margin, $left_margin, $right_margin, $padding, $mode) = @_;
	my($barcode, $path, $mode);
	$path = $::Variable->{BARCODE_DIR} || '';
	$barcode = new Barcode::Code128;
	$barcode->width($width ||= '');
	$barcode->height($height ||= 40);
	$barcode->border($border ||= 0);
	$barcode->scale($scale ||= 1);
	$barcode->font($font ||= "giant");
	$barcode->show_text($show_text ||= 1);
	$barcode->font_margin($font_margin ||= 2);
	$barcode->font_align($font_align ||= "center");
	$barcode->transparent_text($transparent_text ||= 1);
	$barcode->top_margin($top_margin ||= 0);
	$barcode->bottom_margin($bottom_margin ||= 0);
	$barcode->left_margin($left_margin ||= 0);
	$barcode->right_margin($right_margin ||= 0);
	$barcode->padding($padding ||= 10);
	open(PNG, ">$path/$label.png") or die "Can't write $label.png: $!\n";
	print PNG $barcode->png("$label");
	$mode ||= "a+rw";
	system("chmod $mode $path/$label.png");


UserTag code128 Documentation <<EOD
=head1 NAME

ITL tag [code128] -- Create code 128 barcode


	label            = Barcode-Value*
	width            = width
	height           = height
	border           = border
	scale            = scale
	font             = font
	show_text        = show_text
	font_margin      = font_margin
	font_align       = font_align
	transparent_text = transparent_text
	top_margin       = top_margin
	bottom_margin    = bottom_margin
	left_margin      = left_margin
	right_margin     = right_margin
	padding          = padding


Creates a bardoce using the Barcode::Code128 perl module. The resultant 
barcode is a standard image in PNG format. It can them be used as any 
other graphic file. You must have the Barcode::Code128 perl module 
installed for this to work. Example usage is [code128 label="[loop-code]"]

=head2 Options

=over 4

=item label

This is the only required option.  It is the value of the barcode itself.

=item mode

This is file permissions that the resulting image will be set to. 
Default is a+rw  ie. 0666

=item All other options

All other options are well, optional.  You can use them to adjust the 
output.  For a detailed description of what each option does, checkout 
the module documentation at .....


=item Environment Variables

Since the tag creates an image file, it has to know where to put this 
file.  This is specified in the variable.txt file of your catalog. The 
variable name is called BARCODE_DIR and here is an example.

BARCODE_DIR	/tmp/barcodes	Barcodes

The default is the catalog root directory.


=head1 AUTHOR

Marty Tennison

-  - -- ----  ---------------------------- --- -- -   -
Marty Tennison
-  -- --- --------------------------------------- --- --

More information about the interchange-users mailing list