| 1 | package PDF::API2::Resource::XObject::Form::BarCode::codabar; | ||
| 2 | |||
| 3 | 2 | ▶ | use base 'PDF::API2::Resource::XObject::Form::BarCode'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 2 | our $VERSION = '2.044'; # VERSION | |
| 9 | |||
| 10 | sub new { | ||
| 11 | 1 | ▶ | my ($class, $pdf, %options) = @_; |
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||
| 12 | 1 | my $self = $class->SUPER::new($pdf, %options); | |
| 13 | |||
| 14 | 1 | my @bars = $self->encode($options{'-code'}); | |
| 15 | |||
| 16 | 1 | $self->drawbar([@bars], $options{'caption'}); | |
| 17 | |||
| 18 | 1 | return $self; | |
| 19 | } | ||
| 20 | |||
| 21 | 2 | my $codabar = q|0123456789-$:/.+ABCD|; | |
| 22 | |||
| 23 | 2 | my @barcodabar = qw( | |
| 24 | 11111221 11112211 11121121 22111111 11211211 | ||
| 25 | 21111211 12111121 12112111 12211111 21121111 | ||
| 26 | 11122111 11221111 21112121 21211121 21212111 | ||
| 27 | 11212121 aabbabaa ababaaba ababaaba aaabbbaa | ||
| 28 | ); | ||
| 29 | |||
| 30 | sub encode_char { | ||
| 31 | 17 | ▶ | my $self = shift(); |
|
Subroutine
encode_char: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 32 | 17 | my $char = uc shift(); | |
| 33 | 17 | return $barcodabar[index($codabar, $char)]; | |
| 34 | } | ||
| 35 | |||
| 36 | 2 | 1; | |