NAME

Barcode::RM4SCC - Generate Royal Mail 4 State Customer Code (RM4SCC) barcodes and barcode data

SYNOPSIS

use Barcode::RM4SCC;
my $obj = new Barcode::RM4SCC( String => 'WC1E6XY' );
my $pattern = $obj->barcode;

If you have GD installed you can:

my $gdObj = $obj->plot;
# or specify some options:
# my $gdObj = $obj->plot( WithText => 1, QuietZone => 10);
my $image = $gdObj->png;

and, for example, save the image to a file:

open(IMG, ">$aFilename") || die "Cannot open $aFilename: $!";
binmode(IMG);
print IMG $image;
close(IMG);

ABSTRACT

Generate Royal Mail 4 State Customer Code (RM4SCC) barcode data, and images

DESCRIPTION

This module generates the sequence of bars required to encode a particular string as a Royal Mail 4 State Customer Code (RM4SCC) - a kind of height-modulated barcode used for automated postal sorting in the United Kingdom. If you have GD installed you can generate a bitmap image of the barcode, but GD is not required to use the rest of this module.

Data to be encoded may contain only uppercase letters and numbers. This module will ignore invalid characters. The checksum character is generated automatically for you, as are the start and stop bits.

You may notice that this module is not a subclass of GD::Barcode. I did want to integrate this module as much as possible with existing barcode modules, but it seems that GD::Barcode won't handle height-modulated barcodes such as this one. However, I have tried to keep the interface roughly similar.

WARNING

This module has been written in good faith using information from the web. However, this may not match the actual specification for the RM4SCC so you should be very careful before using this module because it may get things wrong - and that may incur delays or even extra charges!

Having said that, the output does seem to match other sources of RM4SCC barcodes when I have compared them. If you do find errors or bugs please report them. See my area on CPAN for contact details.

I am not connected with the Royal Mail. To the best of my knowledge they don't know about this module, and hence there is no approval or endorsement from them.

NOTES

If you intend to use the barcode image, according to references that I read there should be 20 to 24 bars per 25.4mm (1 inch), which means that the image should be printed at a resolution of 80 to 96 pixels per inch. A quiet zone of 2mm should exist around the barcode and this is why the plot() method generates space around the barcode by default.

METHODS

new( %options )

Class method. Given a hash of options, return a new object. See "OPTIONS". This method will die if an object cannot be created - e.g. if a mandatory option is omitted.

barcode()

Return a barcode pattern as a string. The string is a sequence of the digits 0, 1, 2 and 3. The first character represents the leftmost bar, and the final character represents the rightmost bar. Digit 0 means that the bar has no ascender or descender, just the "track". Digit 1 means there is a descender. Digit 2 means there is an ascender. Digit 3 means there is both an ascender and descender.

plot()

Creates and returns a GD object with the barcode image. This method dies if GD cannot be loaded. You may supply options to this routine to affect how the image is drawn - see "OPTIONS". You may then call methods on that GD object, e.g. to render the image data.

OPTIONS

These are the options to new():

String

Required. The string for which you want to generate a barcode. Any invalid characters will be stripped, and the letters will be made uppercase, before use.

NoChecksum

If true, do not include a checksum character in the barcode. In general there should be a checksum, so don't use this option unless you really know what you're doing.

NoStartbit

If true, do not include the start bit bar in the barcode. In general you do want a start bit, so don't use this option unless you really know what you're doing.

NoStopbit

If true, do not include the stop bit bar in the barcode. In general you do want a stop bit, so don't use this option unless you really know what you're doing.

These are the options to plot():

WithText

If true, the input string (after being uppercased and stripped of invalid characters) will be added to the barcode

QuietZone

The size of the "quiet zone" around the image, in pixels. By default this is 8, because that exceeds 2mm when the image is printed from 80 to 96 pixels per inch (see "DESCRIPTION").

BarColour

By default the bars are black. If you really must change the colour set this option to be an array reference of red, green and blue values, each from 0 to 255.

BGColour

By default the background is white. If you really must change the colour set this option to be an array reference of red, green and blue values, each from 0 to 255.

BGTransparent

By default the image is fully opaque. If this is true then we use the GD object's transparent() method to make the background transparent.

SEE ALSO

Information from these URLs was used while writing this module:

  • http://www.dlsoft.com/dlHelps/helps/dbcnet/rm4scc.htm

  • http://www.morovia.com/education/symbology/royalmail.asp

Those websites are not connected with me or this module.

AUTHOR

P Kent

COPYRIGHT AND LICENSE

Copyright 2004 by P Kent

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.