line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#=======================================================================
|
2
|
|
|
|
|
|
|
# ____ ____ _____ _ ____ ___ ____
|
3
|
|
|
|
|
|
|
# | _ \| _ \| ___| _ _ / \ | _ \_ _| |___ \
|
4
|
|
|
|
|
|
|
# | |_) | | | | |_ (_) (_) / _ \ | |_) | | __) |
|
5
|
|
|
|
|
|
|
# | __/| |_| | _| _ _ / ___ \| __/| | / __/
|
6
|
|
|
|
|
|
|
# |_| |____/|_| (_) (_) /_/ \_\_| |___| |_____|
|
7
|
|
|
|
|
|
|
#
|
8
|
|
|
|
|
|
|
# A Perl Module Chain to faciliate the Creation and Modification
|
9
|
|
|
|
|
|
|
# of High-Quality "Portable Document Format (PDF)" Files.
|
10
|
|
|
|
|
|
|
#
|
11
|
|
|
|
|
|
|
# Copyright 1999-2005 Alfred Reibenschuh .
|
12
|
|
|
|
|
|
|
#
|
13
|
|
|
|
|
|
|
#=======================================================================
|
14
|
|
|
|
|
|
|
#
|
15
|
|
|
|
|
|
|
# This library is free software; you can redistribute it and/or
|
16
|
|
|
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
17
|
|
|
|
|
|
|
# License as published by the Free Software Foundation; either
|
18
|
|
|
|
|
|
|
# version 2 of the License, or (at your option) any later version.
|
19
|
|
|
|
|
|
|
#
|
20
|
|
|
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
21
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
22
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
23
|
|
|
|
|
|
|
# Lesser General Public License for more details.
|
24
|
|
|
|
|
|
|
#
|
25
|
|
|
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
26
|
|
|
|
|
|
|
# License along with this library; if not, write to the
|
27
|
|
|
|
|
|
|
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
28
|
|
|
|
|
|
|
# Boston, MA 02111-1307, USA.
|
29
|
|
|
|
|
|
|
#
|
30
|
|
|
|
|
|
|
# $Id: BarCode.pm,v 2.0 2005/11/16 02:18:23 areibens Exp $
|
31
|
|
|
|
|
|
|
#
|
32
|
|
|
|
|
|
|
#=======================================================================
|
33
|
|
|
|
|
|
|
package PDF::API3::Compat::API2::Resource::XObject::Form::BarCode;
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
BEGIN {
|
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
1
|
|
6
|
use PDF::API3::Compat::API2::Util;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
218
|
|
38
|
1
|
|
|
1
|
|
7
|
use PDF::API3::Compat::API2::Basic::PDF::Utils;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
130
|
|
39
|
1
|
|
|
1
|
|
6
|
use PDF::API3::Compat::API2::Resource::XObject::Form::Hybrid;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
1
|
|
7
|
use POSIX;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
1
|
|
4777
|
use vars qw(@ISA $VERSION);
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
171
|
|
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
1
|
|
40
|
@ISA = qw( PDF::API3::Compat::API2::Resource::XObject::Form::Hybrid );
|
46
|
|
|
|
|
|
|
|
47
|
1
|
|
|
|
|
58
|
( $VERSION ) = sprintf '%i.%03i', split(/\./,('$Revision: 2.0 $' =~ /Revision: (\S+)\s/)[0]); # $Date: 2005/11/16 02:18:23 $
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
}
|
50
|
1
|
|
|
1
|
|
7
|
no warnings qw[ deprecated recursion uninitialized ];
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1729
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item $res = PDF::API3::Compat::API2::Resource::XObject::Form::BarCode->new $pdf, %opts
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Returns a barcode-form object.
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub new {
|
59
|
0
|
|
|
0
|
1
|
|
my ($class,$pdf,%opts) = @_;
|
60
|
0
|
|
|
|
|
|
my $self;
|
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
$class = ref $class if ref $class;
|
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
$self=$class->SUPER::new($pdf);
|
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
$self->{' bfont'}=$opts{-font};
|
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
$self->{' umzn'}=$opts{-umzn}; # (u)pper (m)ending (z)o(n)e
|
69
|
0
|
|
|
|
|
|
$self->{' lmzn'}=$opts{-lmzn}; # (l)ower (m)ending (z)o(n)e
|
70
|
0
|
|
|
|
|
|
$self->{' zone'}=$opts{-zone};
|
71
|
0
|
|
|
|
|
|
$self->{' quzn'}=$opts{-quzn}; # (qu)iet (z)o(n)e
|
72
|
0
|
|
0
|
|
|
|
$self->{' ofwt'}=$opts{-ofwt}||0.01; # (o)ver(f)low (w)id(t)h
|
73
|
0
|
|
|
|
|
|
$self->{' fnsz'}=$opts{-fnsz}; # (f)o(n)t(s)i(z)e
|
74
|
0
|
|
0
|
|
|
|
$self->{' spcr'}=$opts{-spcr}||'';
|
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
return($self);
|
77
|
|
|
|
|
|
|
}
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item $res = PDF::API3::Compat::API2::Resource::XObject::Form::BarCode->new_api $api, %opts
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Returns a barcode-form object. This method is different from 'new' that
|
82
|
|
|
|
|
|
|
it needs an PDF::API3::Compat::API2-object rather than a Text::PDF::File-object.
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub new_api {
|
87
|
0
|
|
|
0
|
1
|
|
my ($class,$api,@opts)=@_;
|
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
my $obj=$class->new($api->{pdf},@opts);
|
90
|
0
|
|
|
|
|
|
$obj->{' api'}=$api;
|
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
return($obj);
|
93
|
|
|
|
|
|
|
}
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub outobjdeep {
|
96
|
0
|
|
|
0
|
1
|
|
my ($self, @opts) = @_;
|
97
|
0
|
|
|
|
|
|
$self->SUPER::outobjdeep(@opts);
|
98
|
|
|
|
|
|
|
}
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
my %bar_wdt=(
|
101
|
|
|
|
|
|
|
0 => 0,
|
102
|
|
|
|
|
|
|
1 => 1,
|
103
|
|
|
|
|
|
|
2 => 2,
|
104
|
|
|
|
|
|
|
3 => 3,
|
105
|
|
|
|
|
|
|
4 => 4,
|
106
|
|
|
|
|
|
|
5 => 5,
|
107
|
|
|
|
|
|
|
6 => 6,
|
108
|
|
|
|
|
|
|
7 => 7,
|
109
|
|
|
|
|
|
|
8 => 8,
|
110
|
|
|
|
|
|
|
9 => 9,
|
111
|
|
|
|
|
|
|
'a' => 1,
|
112
|
|
|
|
|
|
|
'b' => 2,
|
113
|
|
|
|
|
|
|
'c' => 3,
|
114
|
|
|
|
|
|
|
'd' => 4,
|
115
|
|
|
|
|
|
|
'e' => 5,
|
116
|
|
|
|
|
|
|
'f' => 6,
|
117
|
|
|
|
|
|
|
'g' => 7,
|
118
|
|
|
|
|
|
|
'h' => 8,
|
119
|
|
|
|
|
|
|
'i' => 9,
|
120
|
|
|
|
|
|
|
'A' => 1,
|
121
|
|
|
|
|
|
|
'B' => 2,
|
122
|
|
|
|
|
|
|
'C' => 3,
|
123
|
|
|
|
|
|
|
'D' => 4,
|
124
|
|
|
|
|
|
|
'E' => 5,
|
125
|
|
|
|
|
|
|
'F' => 6,
|
126
|
|
|
|
|
|
|
'G' => 7,
|
127
|
|
|
|
|
|
|
'H' => 8,
|
128
|
|
|
|
|
|
|
'I' => 9,
|
129
|
|
|
|
|
|
|
);
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub encode {
|
132
|
0
|
|
|
0
|
0
|
|
my $self=shift @_;
|
133
|
0
|
|
|
|
|
|
my $string=shift @_;
|
134
|
0
|
|
|
|
|
|
my @bar;
|
135
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
my @c=split(//,$string);
|
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
@bar = map { [ $self->encode_string($_), $_ ] } @c;
|
|
0
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
|
return(@bar);
|
141
|
|
|
|
|
|
|
}
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub encode_string {
|
144
|
0
|
|
|
0
|
0
|
|
my $self=shift @_;
|
145
|
0
|
|
|
|
|
|
my $string=shift @_;
|
146
|
0
|
|
|
|
|
|
my $bar;
|
147
|
0
|
|
|
|
|
|
my @c=split(//,$string);
|
148
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
foreach my $char (@c) {
|
150
|
0
|
|
|
|
|
|
$bar.=$self->encode_char($char);
|
151
|
|
|
|
|
|
|
}
|
152
|
0
|
|
|
|
|
|
return($bar);
|
153
|
|
|
|
|
|
|
}
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub drawbar {
|
156
|
0
|
|
|
0
|
0
|
|
my $self=shift @_;
|
157
|
0
|
|
|
|
|
|
my @bar=@{shift @_};
|
|
0
|
|
|
|
|
|
|
158
|
0
|
|
|
|
|
|
my $bartext=shift @_;
|
159
|
0
|
|
|
|
|
|
my $ext=shift @_;
|
160
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
my $x=$self->{' quzn'};
|
162
|
0
|
|
|
|
|
|
my ($code,$str,$f,$t,$l,$h,$xo);
|
163
|
0
|
|
|
|
|
|
$self->fillcolor('black');
|
164
|
0
|
|
|
|
|
|
$self->strokecolor('black');
|
165
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
my $bw=1;
|
167
|
0
|
|
|
|
|
|
foreach my $b (@bar) {
|
168
|
0
|
0
|
|
|
|
|
if(ref($b)) {
|
169
|
0
|
|
|
|
|
|
($code,$str)=@{$b};
|
|
0
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
} else {
|
171
|
0
|
|
|
|
|
|
$code=$b;
|
172
|
0
|
|
|
|
|
|
$str=undef;
|
173
|
|
|
|
|
|
|
}
|
174
|
0
|
|
|
|
|
|
$xo=0;
|
175
|
0
|
|
|
|
|
|
foreach my $c (split(//,$code)) {
|
176
|
0
|
|
|
|
|
|
my $w=$bar_wdt{$c};
|
177
|
0
|
|
|
|
|
|
$xo+=$w/2;
|
178
|
0
|
0
|
|
|
|
|
if($c=~/[0-9]/) {
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
179
|
0
|
|
|
|
|
|
$l=$self->{' quzn'} + $self->{' lmzn'};
|
180
|
0
|
|
|
|
|
|
$h=$self->{' quzn'} + $self->{' lmzn'} + $self->{' zone'} + $self->{' umzn'};
|
181
|
0
|
|
|
|
|
|
$t=$self->{' quzn'};
|
182
|
0
|
|
0
|
|
|
|
$f=$self->{' fnsz'}||$self->{' lmzn'};
|
183
|
|
|
|
|
|
|
} elsif($c=~/[a-z]/) {
|
184
|
0
|
|
|
|
|
|
$l=$self->{' quzn'};
|
185
|
0
|
|
|
|
|
|
$h=$self->{' quzn'} + $self->{' lmzn'} + $self->{' zone'} + $self->{' umzn'};
|
186
|
0
|
|
|
|
|
|
$t=$self->{' quzn'} + $self->{' lmzn'} + $self->{' zone'} + $self->{' umzn'};
|
187
|
0
|
|
0
|
|
|
|
$f=$self->{' fnsz'}||$self->{' umzn'};
|
188
|
|
|
|
|
|
|
} elsif($c=~/[A-Z]/) {
|
189
|
0
|
|
|
|
|
|
$l=$self->{' quzn'};
|
190
|
0
|
|
|
|
|
|
$h=$self->{' quzn'} + $self->{' lmzn'} + $self->{' zone'};
|
191
|
0
|
|
0
|
|
|
|
$f=$self->{' fnsz'}||$self->{' umzn'};
|
192
|
0
|
|
|
|
|
|
$t=$self->{' quzn'} + $self->{' lmzn'} + $self->{' zone'} + $self->{' umzn'} - $f;
|
193
|
|
|
|
|
|
|
} else {
|
194
|
0
|
|
|
|
|
|
$l=$self->{' quzn'} + $self->{' lmzn'};
|
195
|
0
|
|
|
|
|
|
$h=$self->{' quzn'} + $self->{' lmzn'} + $self->{' zone'} + $self->{' umzn'};
|
196
|
0
|
|
|
|
|
|
$t=$self->{' quzn'};
|
197
|
0
|
|
0
|
|
|
|
$f=$self->{' fnsz'}||$self->{' lmzn'};
|
198
|
|
|
|
|
|
|
}
|
199
|
0
|
0
|
|
|
|
|
if($bw) {
|
200
|
0
|
0
|
|
|
|
|
if($c ne '0') {
|
201
|
0
|
|
|
|
|
|
$self->linewidth($w-$self->{' ofwt'});
|
202
|
0
|
|
|
|
|
|
$self->move($x+$xo,$l);
|
203
|
0
|
|
|
|
|
|
$self->line($x+$xo,$h);
|
204
|
0
|
|
|
|
|
|
$self->stroke;
|
205
|
|
|
|
|
|
|
}
|
206
|
0
|
|
|
|
|
|
$bw=0;
|
207
|
|
|
|
|
|
|
} else {
|
208
|
0
|
|
|
|
|
|
$bw=1;
|
209
|
|
|
|
|
|
|
}
|
210
|
0
|
|
|
|
|
|
$xo+=$w/2;
|
211
|
|
|
|
|
|
|
}
|
212
|
0
|
0
|
0
|
|
|
|
if(defined($str) && ($self->{' lmzn'}>0)) {
|
213
|
0
|
|
|
|
|
|
$str=join($self->{' spcr'},split(//,$str));
|
214
|
0
|
|
|
|
|
|
$self->textstart;
|
215
|
0
|
|
|
|
|
|
$self->translate($x+($xo/2),$t);
|
216
|
0
|
|
|
|
|
|
$self->font($self->{' bfont'},$f);
|
217
|
0
|
|
|
|
|
|
$self->text_center($str);
|
218
|
0
|
|
|
|
|
|
$self->textend;
|
219
|
|
|
|
|
|
|
}
|
220
|
0
|
|
|
|
|
|
$x+=$xo;
|
221
|
|
|
|
|
|
|
}
|
222
|
0
|
0
|
|
|
|
|
if(defined $bartext) {
|
223
|
0
|
|
0
|
|
|
|
$f=$self->{' fnsz'}||$self->{' lmzn'};
|
224
|
0
|
|
|
|
|
|
$t=$self->{' quzn'}-$f;
|
225
|
0
|
|
|
|
|
|
$self->textstart;
|
226
|
0
|
|
|
|
|
|
$self->translate(($self->{' quzn'}+$x)/2,$t);
|
227
|
0
|
|
|
|
|
|
$self->font($self->{' bfont'},$f);
|
228
|
0
|
|
|
|
|
|
$self->text_center($bartext);
|
229
|
0
|
|
|
|
|
|
$self->textend;
|
230
|
|
|
|
|
|
|
}
|
231
|
0
|
|
|
|
|
|
$self->{' w'}=$self->{' quzn'}+$x;
|
232
|
0
|
|
|
|
|
|
$self->{' h'}=2*$self->{' quzn'} + $self->{' lmzn'} + $self->{' zone'} + $self->{' umzn'};
|
233
|
0
|
|
|
|
|
|
$self->{BBox}=PDFArray(PDFNum(0),PDFNum(0),PDFNum($self->{' w'}),PDFNum($self->{' h'}));
|
234
|
|
|
|
|
|
|
}
|
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=item $wd = $bc->width
|
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=cut
|
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
sub width {
|
241
|
0
|
|
|
0
|
1
|
|
my $self = shift @_;
|
242
|
0
|
|
|
|
|
|
return($self->{' w'});
|
243
|
|
|
|
|
|
|
}
|
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=item $ht = $bc->height
|
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=cut
|
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
sub height {
|
250
|
0
|
|
|
0
|
1
|
|
my $self = shift @_;
|
251
|
0
|
|
|
|
|
|
return($self->{' h'});
|
252
|
|
|
|
|
|
|
}
|
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
1;
|
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
__END__
|