The Perl Toolchain Summit 2025 Needs You: You can help 🙏 Learn more
123456789—101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 package PDF::Builder::Resource::XObject::Form::BarCode::codabar;use base 'PDF::Builder::Resource::XObject::Form::BarCode';use strict;use warnings;our $VERSION = '3.026'; # VERSIONour $LAST_UPDATE = '3.026'; # manually update whenever code is changedHideShow 19 lines of Pod=head1 NAMEPDF::Builder::Resource::XObject::Form::BarCode::codabar - specific information for CodaBar bar codes. Inherits from L<PDF::Builder::Resource::XObject::Form::BarCode>=head1 METHODS=head2 new PDF::Builder::Resource::XObject::Form::BarCode::codabar->new()=overCreate a Codabar bar code object. Note that it is invoked from the Builder.pmlevel method!=back=cut# TBD document code, caption optionssub new { my ($class, $pdf, %options) = @_; # copy dashed option names to preferred undashed names if (defined $options{'-code'} && !defined $options{'code'}) { $options{'code'} = delete($options{'-code'}); } my $self = $class->SUPER::new($pdf, %options); my @bars = $self->encode($options{'code'}); $self->drawbar([@bars], $options{'caption'}); return $self;}# allowed alphabet and translation to bar widthsmy $codabar = q|0123456789-$:/.+ABCD|;my @barcodabar = qw( 11111221 11112211 11121121 22111111 11211211 21111211 12111121 12112111 12211111 21121111 11122111 11221111 21112121 21211121 21212111 11212121 aabbabaa ababaaba ababaaba aaabbbaa);sub encode_char { my $self = shift; my $char = uc(shift()); return $barcodabar[index($codabar, $char)];}1;
package
PDF::Builder::Resource::XObject::Form::BarCode::codabar;
use
base
'PDF::Builder::Resource::XObject::Form::BarCode'
;
strict;
warnings;
our
$VERSION
=
'3.026'
# VERSION
$LAST_UPDATE
# manually update whenever code is changed
=head1 NAME
PDF::Builder::Resource::XObject::Form::BarCode::codabar - specific information for CodaBar bar codes. Inherits from L<PDF::Builder::Resource::XObject::Form::BarCode>
=head1 METHODS
=head2 new
PDF::Builder::Resource::XObject::Form::BarCode::codabar->new()
=over
Create a Codabar bar code object. Note that it is invoked from the Builder.pm
level method!
=back
=cut
# TBD document code, caption options
sub
new {
my
(
$class
,
$pdf
%options
) =
@_
# copy dashed option names to preferred undashed names
if
defined
$options
{
'-code'
} && !
'code'
}) {
} =
delete
}); }
$self
->SUPER::new(
);
@bars
->encode(
});
->drawbar([
],
'caption'
return
}
# allowed alphabet and translation to bar widths
$codabar
q|0123456789-$:/.+ABCD|
@barcodabar
qw(
11111221 11112211 11121121 22111111 11211211
21111211 12111121 12112111 12211111 21121111
11122111 11221111 21112121 21211121 21212111
11212121 aabbabaa ababaaba ababaaba aaabbbaa
)
encode_char {
shift
$char
uc
());
$barcodabar
[
index
)];
1;