Barcode-Code128
view release on metacpan or search on metacpan
- Changes suggested by Lance Held <lheld@nanogen.com>:
* Add $preferred_code option to encode() to allow user to specify a
preference of e.g. code B
* Modify _encodable to not be so eager to switch to code C
- Make GD optional; support either GIF or PNG (Add gd_image
and gif methods)
- Add scale option to gif, png, gd_image
- Alter gd_image to use options
- Update diagnostics section to match same sequence they appear in code
- Add font_align option (courtesy Gavin Brock <gavin.brock@nssmb.com>)
- Add transparent_text option
2.01 Tue Jul 17 13:07:04 PDT 2007
- Change AUTOLOAD to not try to call destroy()
As suggested in http://rt.cpan.org/Public/Bug/Display.html?id=14850
2.20 Tue Mar 29 11:51:38 CDT 2011
- Fixed tests to avoid failures, upgrade tests to Test::More
(courtesy Mark A. Stratman <stratman@gmail.com>)
- Remove conditional support for GIF/PNG as all new versions
since 2004 of GD should support both
lib/Barcode/Code128.pm view on Meta::CPAN
scale => 2,
font => 'large',
show_text => 1,
font_margin => 2,
top_margin => 0,
bottom_margin => 0,
left_margin => 0,
right_margin => 0,
padding => 20,
font_align => 'left',
transparent_text => 1,
);
@EXPORT_OK = qw(CodeA CodeB CodeC FNC1 FNC2 FNC3 FNC4 Shift StartA
StartB StartC Stop);
%EXPORT_TAGS = (all => \@EXPORT_OK);
@ISA = qw(Exporter);
# Version information
$VERSION = '2.21';
lib/Barcode/Code128.pm view on Meta::CPAN
The valid options, and the default value and meaning of each, are:
width undef Width of the image (*)
height undef Height of the image (*)
border 2 Size of the black border around the barcode
scale 2 How many pixels for the smallest barcode stripe
font "large" Font (**) for the text at the bottom
show_text 1 True/False: display the text at the bottom?
font_margin 2 Pixels above, below, and to left of the text
font_align "left" Align the text ("left", "right", or "center")
transparent_text 1/0(***) True/False: use transparent background for text?
top_margin 0 No. of pixels above the barcode
bottom_margin 0 No. of pixels below the barcode (& text)
left_margin 0 No. of pixels to the left of the barcode
right_margin 0 No. of pixels to the right of the barcode
padding 20 Size of whitespace before & after barcode
* Width and height are the default values for the $x and $y arguments
to the png, gif, or gd_image method (q.v.)
** Font may be one of the following: "giant", "large", "medium",
"small", or "tiny". Or, it may be any valid GD font name, such as
"gdMediumFont".
*** The "transparent_text" option is "1" (true) by default for GIF
output, but "0" (false) for PNG. This is because PNG transparency is
not supported well by many viewing software The background color is
grey (#CCCCCC) when not transparent.
=cut
sub AUTOLOAD
{
my($self, @args) = @_;
use vars qw($AUTOLOAD);
(my $opt = lc $AUTOLOAD) =~ s/^.*:://;
return if $opt eq 'destroy';
$self->option($opt, @args);
lib/Barcode/Code128.pm view on Meta::CPAN
$x ||= $min_x;
$y ||= $min_y;
croak "Image width $x is too small for bar code" if $x < $min_x;
croak "Image height $y is too small for bar code" if $y < $min_y;
my $image = new GD::Image($x + $lm + $rm, $y + $tm + $bm + $font_height)
or croak "Unable to create $x x $y image";
my $grey = $image->colorAllocate(0xCC, 0xCC, 0xCC);
my $white = $image->colorAllocate(0xFF, 0xFF, 0xFF);
my $black = $image->colorAllocate(0x00, 0x00, 0x00);
my $red = $image->colorAllocate(0xFF, 0x00, 0x00);
$image->transparent($grey)
if $opts{transparent_text};
if ($border) {
$image->rectangle($lm, $tm, $lm+$x-1, $tm+$y-1, $black);
$image->rectangle($lm+$border, $tm+$border,
$lm+$x-$border-1, $tm+$y-$border-1, $black);
$image->fill($lm+1, $tm+1, $black);
}
else {
$image->rectangle($lm, $tm, $lm+$x-1, $tm+$y-1, $white);
}
$image->fill($lm+$border+1, $tm+$border+1, $white);
lib/Barcode/Code128.pm view on Meta::CPAN
This is a serious error in C<code()> that indicates an invalid
argument was supplied. Only the codes (A, B, or C) of CODE 128 may be
supplied here. If you get this error please contact the author.
=back
=head1 BUGS
At least some Web browsers do not seem to handle PNG files with
transparent backgrounds correctly. As a result, the default for PNG
is to generate barcodes without transparent backgrounds - the
background is grey instead.
=head1 AUTHOR
William R. Ward, wrw@bayview.com
=head1 SEE ALSO
perl(1), GD
( run in 0.288 second using v1.01-cache-2.11-cpan-a1d94b6210f )