line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package PDF::Labels::Layout::Simple; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1196
|
use vars qw(@ISA); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
63
|
|
5
|
1
|
|
|
1
|
|
6
|
use base qw(PDF::Labels::Layout); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
83
|
|
6
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
958
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub line_count { |
9
|
|
|
|
|
|
|
|
10
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
11
|
|
|
|
|
|
|
|
12
|
0
|
0
|
|
|
|
|
if ( @_ ) { |
13
|
0
|
|
|
|
|
|
$self->{'line_count'} = shift; |
14
|
|
|
|
|
|
|
} |
15
|
0
|
0
|
|
|
|
|
$self->{'line_count'} = 4 if $self->{'line_count'} < 1; |
16
|
0
|
|
|
|
|
|
return $self->{'line_count'}; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub font { |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
23
|
0
|
|
|
|
|
|
my $line=shift; |
24
|
0
|
|
|
|
|
|
my $size=shift; |
25
|
|
|
|
|
|
|
|
26
|
0
|
0
|
|
|
|
|
return if $line > $self->line_count; |
27
|
|
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
|
if ( $size ) { |
29
|
0
|
|
|
|
|
|
$self->{'font'}[$line] = $size; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
return exists $self->{'font'}[$line] ? $self->{'font'}[$line] : $self->font_default; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub fontsize { |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
39
|
0
|
|
|
|
|
|
my $line=shift; |
40
|
0
|
|
|
|
|
|
my $size=shift; |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
return if $line > $self->line_count; |
43
|
|
|
|
|
|
|
|
44
|
0
|
0
|
|
|
|
|
if ( $size ) { |
45
|
0
|
|
|
|
|
|
$self->{'fontsize'}[$line] = $size; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
return exists $self->{'fontsize'}[$line] ? $self->{'fontsize'}[$line] : $self->fontsize_default; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub prep { |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
55
|
0
|
|
|
|
|
|
my %opts=@_; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$self->{'_pdf'}=$opts{pdf}; |
58
|
0
|
|
|
|
|
|
$self->{'_font_default'} = $self->{'_pdf'}->corefont($self->font_default, 1); |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
my $t_fontsize=0; |
61
|
0
|
|
|
|
|
|
for my $l ( 0 ... $self->line_count - 1) { |
62
|
0
|
|
|
|
|
|
$self->{'_font'}[$l] = $self->{'_pdf'}->corefont( $self->font($l), 1); |
63
|
0
|
|
|
|
|
|
$t_fontsize += $self->fontsize($l); |
64
|
0
|
|
0
|
|
|
|
$self->{'_align'}[$l] ||= $self->align_default; |
65
|
|
|
|
|
|
|
}; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my $leading= ( -$opts{'size'}[1] - $self->margin_top -$self->margin_bottom - $t_fontsize) / ($self->line_count - 1); |
68
|
0
|
|
|
|
|
|
$self->{'_baseline'}[0] = $self->margin_top + $self->fontsize(0); |
69
|
0
|
|
|
|
|
|
for my $l ( 1 ... $self->line_count - 1) { |
70
|
0
|
|
|
|
|
|
$self->{'_baseline'}[$l] = $self->{'_baseline'}[$l-1] + $self->fontsize($l) + $leading; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub print { |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
0
|
0
|
|
my $self=shift; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
$self->SUPER::print( @_ ); |
81
|
0
|
|
|
|
|
|
my $opts=$self->{'_opts'}; |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
my @pos=@{$self->{'_pos'}}; |
|
0
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
my $text = $self->{'_page'}->text; |
86
|
0
|
|
|
|
|
|
my $data = $self->{'_data'}; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
for my $l ( 0 ... $self->line_count - 1 ) { |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
my $size = $self->fontsize($l); |
91
|
0
|
|
|
|
|
|
my $line= $data->[$l]; |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
$text->font( $self->{'_font'}[$l], $size ); |
94
|
0
|
|
|
|
|
|
while ($text->advancewidth($line) > ($pos[2] - $self->margin_left - $self->margin_right) ) { |
95
|
0
|
|
|
|
|
|
$size -= 1; |
96
|
0
|
0
|
|
|
|
|
die "Text '$line' is too big to fit on line!\n" if $size < 6; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
0
|
0
|
|
|
|
|
if ( $self->{'_align'}[$l] eq "center" ) { |
101
|
0
|
|
|
|
|
|
$text->translate( $pos[0] + $pos[2]/2, $pos[1] - $self->{'_baseline'}[$l] ); |
102
|
0
|
|
|
|
|
|
$text->text_center( $line ); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
0
|
0
|
|
|
|
|
if ( $self->{'_align'}[$l] eq "left" ) { |
106
|
0
|
|
|
|
|
|
$text->translate( $pos[0] + $self->margin_left, $pos[1] - $self->{'_baseline'}[$l] ); |
107
|
0
|
|
|
|
|
|
$text->text( $line ); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
0
|
0
|
|
|
|
|
if ( $self->{'_align'}[$l] eq "right" ) { |
111
|
0
|
|
|
|
|
|
$text->translate( $pos[0] + $pos[2] - $self->margin_right, $pos[1] - $self->{'_baseline'}[$l] ); |
112
|
0
|
|
|
|
|
|
$text->text_right( $line ); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1; |
120
|
|
|
|
|
|
|
|