| 1 | package PDF::API2::Resource::XObject::Form::BarCode::qrcode; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use base 'PDF::API2::Resource::XObject::Form::BarCode'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 1 | our $VERSION = '2.044'; # VERSION | |||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | 1 | our @CARP_NOT = qw(PDF::API2); | |||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | sub new { | ||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | my ($class, $pdf, %options) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 16 | 0 | my $self = $class->SUPER::new($pdf, %options); | |||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | 0 | eval { | |||||||||||||||||||||||||||||||
| 19 | 0 | require Text::QRCode; | |||||||||||||||||||||||||||||||
| 20 | }; | ||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 22 | 0 | croak "Error loading Text::QRCode: $@"; | |||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | my $mode = $options{'mode'} // '8-bit'; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$options{"mode"} // "8-bit"
MC/DC0%0/1
$options{"mode"} // "8-bit"
$options{"mode"}
Truth table0%0/2
A
A= $options{"mode"}
| |||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | $mode = 'numerical' if $mode eq 'numeric'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | $mode = 'alpha-numerical' if $mode eq 'alphanumeric'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | $mode = 'alpha-numerical' if $mode eq 'alpha-numeric'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | my $generator = Text::QRCode->new( | ||||||||||||||||||||||||||||||||
| 31 | level => ($options{'error_correction'} // 'L'), | ||||||||||||||||||||||||||||||||
| 32 | version => ($options{'version'} // 0), | ||||||||||||||||||||||||||||||||
| 33 | mode => $mode, | ||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | casesensitive => ($options{'case_sensitive'} // 1), | ||||||||||||||||||||||||||||||
|
Condition0%0/6
$options{"error_correction"} // "L"
$options{"version"} // 0
$options{"case_sensitive"} // 1
MC/DC0%0/1
$options{"error_correction"} // "L"
$options{"error_correction"}
MC/DC0%0/1
$options{"version"} // 0
$options{"version"}
MC/DC0%0/1
$options{"case_sensitive"} // 1
$options{"case_sensitive"}
Truth table0%0/2
A
A= $options{"error_correction"}
Truth table0%0/2
A
A= $options{"version"}
Truth table0%0/2
A
A= $options{"case_sensitive"}
| |||||||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||
| 37 | 0 | my $lines_ref = $generator->plot($options{'code'}); | |||||||||||||||||||||||||||||||
| 38 | 0 | my @lines = reverse map { join('', @$_) } @$lines_ref; | |||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||
| 40 | 0 | $self->render(@lines); | |||||||||||||||||||||||||||||||
| 41 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | sub render { | ||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | my ($self, @lines) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
render: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | 0 | $self->fillcolor($self->{' color'}); | |||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | 0 | my $y = $self->{' quzn'}; | |||||||||||||||||||||||||||||||
| 50 | 0 | my $w = $self->{' mils'} / 1000 * 72; | |||||||||||||||||||||||||||||||
| 51 | 0 | my $h = $self->{' zone'}; | |||||||||||||||||||||||||||||||
| 52 | 0 | foreach my $line (@lines) { | |||||||||||||||||||||||||||||||
| 53 | 0 | my $x = $self->{' quzn'}; | |||||||||||||||||||||||||||||||
| 54 | 0 | foreach my $char (split m//, $line) { | |||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | if ($char eq '*') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 56 | 0 | $self->rectangle($x, $y, $x + $w, $y + $h); | |||||||||||||||||||||||||||||||
| 57 | 0 | $self->fill(); | |||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||
| 59 | 0 | $x += $w; | |||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||
| 61 | 0 | $y += $h; | |||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||
| 64 | 0 | $self->{' w'} = 2 * $self->{' quzn'} + length($lines[0]) * $w; | |||||||||||||||||||||||||||||||
| 65 | 0 | $self->{' h'} = 2 * $self->{' quzn'} + length($lines[0]) * $h; | |||||||||||||||||||||||||||||||
| 66 | 0 | $self->bbox(0, 0, $self->{' w'}, $self->{' h'}); | |||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||
| 68 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||
| 71 | 1 | 1; | |||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||
| 73 | __END__ | ||||||||||||||||||||||||||||||||