line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::ReportWriter::Pdf; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
26371
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
4
|
1
|
|
|
1
|
|
872
|
use POSIX qw(setlocale LC_NUMERIC); |
|
1
|
|
|
|
|
8365
|
|
|
1
|
|
|
|
|
9
|
|
5
|
1
|
|
|
1
|
|
2575
|
use utf8; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
4
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
39
|
use base 'Business::ReportWriter'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
639
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub init_fields { |
10
|
0
|
|
|
0
|
0
|
|
my ( $self, $parms ) = @_; |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
|
|
|
$self->SUPER::fields($parms); |
13
|
0
|
0
|
|
|
|
|
my @fields = @$parms if $parms; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Find maximum line height |
16
|
0
|
|
|
|
|
|
$self->{font}{maxheight} = 8; |
17
|
0
|
|
|
|
|
|
for ( 0 .. $#{ $self->{report}{fields} } ) { |
|
0
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
$self->{fields}{ $fields[$_]{name} } = $_; |
19
|
0
|
0
|
0
|
|
|
|
if ( defined( $fields[$_]{font}{size} ) |
20
|
|
|
|
|
|
|
&& $fields[$_]{font}{size} > $self->{font}{_maxheight} ) |
21
|
|
|
|
|
|
|
{ |
22
|
0
|
|
|
|
|
|
$self->{font}{_maxheight} = $fields[$_]{font}{size}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub init_breaks { |
28
|
0
|
|
|
0
|
0
|
|
my ( $self, $parms ) = @_; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
$self->SUPER::breaks($parms); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Find total break height |
33
|
0
|
|
|
|
|
|
$| = 1; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
for ( keys %$parms ) { |
36
|
0
|
0
|
|
|
|
|
next if /^_/; |
37
|
0
|
|
|
|
|
|
my $brk = $parms->{$_}; |
38
|
0
|
|
0
|
|
|
|
my $hbs = $brk->{beforespace} || 0; |
39
|
0
|
|
|
|
|
|
my $hts = 10; |
40
|
0
|
|
|
|
|
|
my $hfhs = 10; |
41
|
0
|
|
|
|
|
|
my $ts = 10; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# $self->{fields}{$fields[$_]{name}} = $_; |
44
|
|
|
|
|
|
|
# if (defined($fields[$_]{font}{size}) && |
45
|
|
|
|
|
|
|
# $fields[$_]{font}{size} > $self->{font}{_maxheight}) { |
46
|
|
|
|
|
|
|
# $self->{font}{_maxheight} = $fields[$_]{font}{size}; |
47
|
|
|
|
|
|
|
# } |
48
|
0
|
|
|
|
|
|
$brk->{breakheight} = $hbs + $hts + $hfhs + $ts; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Routines for report writing |
53
|
|
|
|
|
|
|
sub calc_yoffset { |
54
|
0
|
|
|
0
|
0
|
|
my ( $self, $fontsize ) = @_; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
$self->{ypos} -= $fontsize + 2; |
57
|
0
|
|
|
|
|
|
$self->check_page; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
return $self->{ypos}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub page_footer { |
63
|
0
|
|
|
0
|
0
|
|
my ( $self, $fontsize ) = @_; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $break = '_page'; |
66
|
0
|
|
|
|
|
|
$self->{breaks}{$break} = '_break'; |
67
|
0
|
|
|
|
|
|
my $text = $self->make_text( 0, $self->{report}{breaks}{$break}{text} ); |
68
|
0
|
|
|
|
|
|
$self->{breaktext}{$break} = $text; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#$self->print_break(); |
71
|
0
|
|
|
|
|
|
$self->{breaks}{$break} = ""; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub header_text { |
75
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $page = $self->{pageData}; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
for my $th ( @{ $self->{report}{page}{text} } ) { |
|
0
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
$self->process_field( $th, $page ); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub print_pagenumber { |
85
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
my $page = $self->{report}{page}; |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
my $text = $page->{number}{text} . $self->{pageData}{pagenr}; |
90
|
0
|
|
|
|
|
|
$self->out_field( $text, $page->{number} ); |
91
|
0
|
0
|
|
|
|
|
$self->calc_yoffset( $self->{font}{size} ) |
92
|
|
|
|
|
|
|
unless $page->{number}{sameline}; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub print_pageheader { |
96
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
my $page = $self->{pageData}; |
99
|
0
|
|
|
|
|
|
$self->{ypos} = $self->{paper}{topmargen}; |
100
|
|
|
|
|
|
|
|
101
|
0
|
0
|
|
|
|
|
$self->{ypos} -= mm_to_pt( $self->{report}{page}{number}{ypos} ) |
102
|
|
|
|
|
|
|
if $page->{number}{ypos}; |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
$self->header_text(); |
105
|
0
|
|
|
|
|
|
$self->print_pagenumber; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub start_body { |
109
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
my $body = $self->{report}{body}; |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
$self->set_font( $body->{font} ); |
114
|
0
|
0
|
|
|
|
|
$self->{ypos} = $self->{paper}{topmargen} - mm_to_pt( $body->{ypos} ) |
115
|
|
|
|
|
|
|
if $body->{ypos}; |
116
|
0
|
0
|
|
|
|
|
my $heigth = mm_to_pt( $body->{heigth} ) if $body->{heigth}; |
117
|
0
|
0
|
|
|
|
|
$heigth += mm_to_pt( $body->{ypos} ) if $body->{ypos}; |
118
|
0
|
0
|
|
|
|
|
$self->{paper}{heigth} = $heigth if $heigth; |
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
$self->make_field_headers( $body->{FieldHeaders} ); |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
$self->{inHeader} = 0; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub draw_graphics { |
126
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
my $p = $self->{pdf}; |
129
|
0
|
|
|
|
|
|
my $graphics = $self->{report}{graphics}; |
130
|
0
|
0
|
|
|
|
|
$p->set_gfxlinewidth( $graphics->{width} + 0 ) |
131
|
|
|
|
|
|
|
if defined( $graphics->{width} ); |
132
|
0
|
|
|
|
|
|
for ( @{ $graphics->{boxes} } ) { |
|
0
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
my $bottomy = $self->{paper}{topmargen} - mm_to_pt( $_->{bottomy} ); |
134
|
0
|
|
|
|
|
|
my $topy = $self->{paper}{topmargen} - mm_to_pt( $_->{topy} ); |
135
|
0
|
|
|
|
|
|
$p->draw_rect( |
136
|
|
|
|
|
|
|
mm_to_pt( $_->{topx} ), $bottomy, |
137
|
|
|
|
|
|
|
mm_to_pt( $_->{bottomx} ), $topy |
138
|
|
|
|
|
|
|
); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub draw_logos { |
143
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
144
|
|
|
|
|
|
|
|
145
|
0
|
|
|
|
|
|
my $p = $self->{pdf}; |
146
|
0
|
|
|
|
|
|
my $logos = $self->{report}{logo}; |
147
|
0
|
|
|
|
|
|
for ( @{ $logos->{logo} } ) { |
|
0
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
|
my $x = mm_to_pt( $_->{x} ); |
149
|
0
|
|
|
|
|
|
my $y = $self->{paper}{topmargen} - mm_to_pt( $_->{y} ); |
150
|
0
|
|
|
|
|
|
$p->add_img_scaled( $_->{name}, $x, $y, $_->{scale} ); |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub new_page { |
155
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
156
|
|
|
|
|
|
|
|
157
|
0
|
|
|
|
|
|
$self->{inHeader} = 1; |
158
|
0
|
|
|
|
|
|
my $p = $self->{pdf}; |
159
|
0
|
|
|
|
|
|
$self->{pageData}{pagenr}++; |
160
|
0
|
|
|
|
|
|
$self->{breaks}{'_page'} = ""; |
161
|
0
|
0
|
|
|
|
|
$self->page_footer() if $self->{pageData}{pagenr} > 1; |
162
|
0
|
|
|
|
|
|
$self->{ypos} = $self->{paper}{topmargen}; |
163
|
0
|
|
|
|
|
|
$p->new_page; |
164
|
0
|
|
|
|
|
|
$self->set_font( $self->{report}{page}{font} ); |
165
|
0
|
0
|
|
|
|
|
$self->print_pageheader() if defined( $self->{report}{page} ); |
166
|
0
|
|
|
|
|
|
$self->start_body(); |
167
|
0
|
|
|
|
|
|
$self->draw_graphics(); |
168
|
0
|
|
|
|
|
|
$self->draw_logos(); |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub text_color { |
172
|
0
|
|
|
0
|
0
|
|
my ( $self, $color ) = @_; |
173
|
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
my $p = $self->{pdf}; |
175
|
0
|
|
|
|
|
|
$p->set_textcolor($color); |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub set_linecolor { |
179
|
0
|
|
|
0
|
0
|
|
my ( $self, $fld_fgcolor ) = @_; |
180
|
|
|
|
|
|
|
|
181
|
0
|
0
|
0
|
|
|
|
my $fgcolor = |
182
|
|
|
|
|
|
|
$fld_fgcolor |
183
|
|
|
|
|
|
|
? $fld_fgcolor |
184
|
|
|
|
|
|
|
: $self->{report}{textcolor} || 'black'; |
185
|
0
|
|
|
|
|
|
$self->text_color($fgcolor); |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub draw_topline { |
189
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
190
|
|
|
|
|
|
|
|
191
|
0
|
|
|
|
|
|
my $p = $self->{pdf}; |
192
|
0
|
|
|
|
|
|
my $width = $self->{paper}{width} - 20; |
193
|
0
|
|
|
|
|
|
my $ypos = $self->{ypos} - 3; |
194
|
0
|
|
|
|
|
|
$p->draw_line( 10, $ypos, $width, $ypos ); |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub draw_underline { |
198
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
199
|
|
|
|
|
|
|
|
200
|
0
|
|
|
|
|
|
my $p = $self->{pdf}; |
201
|
0
|
|
|
|
|
|
my $width = $self->{paper}{width} - 20; |
202
|
0
|
|
|
|
|
|
my $ypos = $self->{ypos} - $self->{font}{size} - 3; |
203
|
0
|
|
|
|
|
|
$p->draw_line( 10, $ypos, $width, $ypos ); |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
sub draw_linebox { |
207
|
0
|
|
|
0
|
0
|
|
my ( $self, $shade ) = @_; |
208
|
|
|
|
|
|
|
|
209
|
0
|
|
|
|
|
|
my $p = $self->{pdf}; |
210
|
0
|
|
|
|
|
|
my $width = $self->{paper}{width} - 20; |
211
|
0
|
|
|
|
|
|
my $ypos = $self->{ypos} - 3; |
212
|
0
|
|
|
|
|
|
my $fontsize = $self->{font}{size} + 2; |
213
|
0
|
|
|
|
|
|
$p->shade_rect( 10, $ypos, $width, $ypos - $fontsize, $shade ); |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
sub begin_break { |
217
|
0
|
|
|
0
|
0
|
|
my ( $self, $rec, $fld ) = @_; |
218
|
|
|
|
|
|
|
|
219
|
0
|
|
|
|
|
|
$self->check_page( $fld->{breakheight} ); |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub begin_line { |
223
|
0
|
|
|
0
|
0
|
|
my ( $self, $rec, $fld ) = @_; |
224
|
|
|
|
|
|
|
|
225
|
0
|
|
|
|
|
|
$self->set_font( $rec->{font} ); |
226
|
0
|
0
|
|
|
|
|
$self->calc_yoffset( $fld->{beforespace} ) if $fld->{beforespace}; |
227
|
0
|
|
|
|
|
|
$self->set_linecolor( $fld->{fgcolor} ); |
228
|
0
|
0
|
|
|
|
|
$self->draw_linebox( $fld->{shade} ) if $fld->{shade}; |
229
|
0
|
0
|
|
|
|
|
$self->draw_topline if $rec->{topline}; |
230
|
0
|
0
|
|
|
|
|
$self->draw_underline if $rec->{underline}; |
231
|
0
|
|
|
|
|
|
$self->calc_yoffset( $self->{font}{size} ); |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
sub begin_field { |
235
|
0
|
|
|
0
|
0
|
|
my ( $self, $field ) = @_; |
236
|
|
|
|
|
|
|
|
237
|
0
|
|
|
|
|
|
$self->set_font( $field->{font} ); |
238
|
0
|
|
|
|
|
|
my $fontsize = $self->{font}{size}; |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
sub out_field { |
242
|
0
|
|
|
0
|
0
|
|
my ( $self, $text, $field, $alt ) = @_; |
243
|
|
|
|
|
|
|
|
244
|
0
|
|
0
|
|
|
|
my $font = $alt->{font} || $field->{font}; |
245
|
0
|
|
|
|
|
|
$self->set_font($font); |
246
|
0
|
0
|
|
|
|
|
$self->{ypos} = $self->{paper}{topmargen} - mm_to_pt( $field->{ypos} ) |
247
|
|
|
|
|
|
|
if $field->{ypos}; |
248
|
0
|
0
|
0
|
|
|
|
$self->calc_yoffset( $self->{font}{size} ) |
249
|
|
|
|
|
|
|
if defined( $field->{nl} ) && $text; |
250
|
0
|
|
|
|
|
|
my $width = mm_to_pt( $field->{width} ); |
251
|
0
|
|
|
|
|
|
$self->out_text( $text, $field->{xpos}, $self->{ypos}, $field->{align}, |
252
|
|
|
|
|
|
|
$width ); |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
sub set_font { |
257
|
0
|
|
|
0
|
0
|
|
my ( $self, $font ) = @_; |
258
|
|
|
|
|
|
|
|
259
|
0
|
|
|
|
|
|
my $p = $self->{pdf}; |
260
|
0
|
0
|
|
|
|
|
if ( defined($font) ) { |
261
|
0
|
0
|
|
|
|
|
if ( $font->{size} ) { |
262
|
0
|
|
|
|
|
|
my $font_size = $font->{size} + 0; |
263
|
0
|
0
|
|
|
|
|
$p->set_size( $font->{size} ) if $self->{font}{size} != $font_size; |
264
|
0
|
|
|
|
|
|
$self->{font}{size} = $font_size; |
265
|
|
|
|
|
|
|
} |
266
|
0
|
0
|
|
|
|
|
if ( $font->{face} ) { |
267
|
0
|
0
|
|
|
|
|
$p->set_font( $font->{face} ) |
268
|
|
|
|
|
|
|
if $self->{font}{face} ne $font->{face}; |
269
|
0
|
|
|
|
|
|
$self->{font}{face} = $font->{face}; |
270
|
|
|
|
|
|
|
} |
271
|
|
|
|
|
|
|
} |
272
|
|
|
|
|
|
|
} |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
sub begin_list { |
275
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
276
|
|
|
|
|
|
|
|
277
|
0
|
|
0
|
|
|
|
my $papersize = $self->{report}{papersize} || 'A4'; |
278
|
0
|
|
0
|
|
|
|
my $orientation = $self->{report}{orientation} || 'Portrait'; |
279
|
0
|
|
|
|
|
|
my $p = new Business::ReportWriter::Pdf::Report( |
280
|
|
|
|
|
|
|
PageSize => $papersize, |
281
|
|
|
|
|
|
|
PageOrientation => $orientation |
282
|
|
|
|
|
|
|
); |
283
|
|
|
|
|
|
|
|
284
|
0
|
|
|
|
|
|
$self->{pdf} = $p; |
285
|
0
|
|
|
|
|
|
$self->{ypos} = -1; |
286
|
0
|
|
|
|
|
|
$self->set_papersize(); |
287
|
|
|
|
|
|
|
} |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
sub check_page { |
290
|
0
|
|
|
0
|
0
|
|
my ( $self, $yplus ) = @_; |
291
|
|
|
|
|
|
|
|
292
|
0
|
0
|
|
|
|
|
return if $self->{inHeader}; |
293
|
0
|
|
|
|
|
|
my $bottommargen = $self->{paper}{topmargen} - $self->{paper}{heigth}; |
294
|
0
|
0
|
|
|
|
|
$self->new_page() if $self->{ypos} - $yplus < $bottommargen; |
295
|
|
|
|
|
|
|
} |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
sub get_doc { |
298
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
299
|
|
|
|
|
|
|
|
300
|
0
|
|
|
|
|
|
my $p = $self->{pdf}; |
301
|
0
|
|
|
|
|
|
$p->finish_report("none"); |
302
|
|
|
|
|
|
|
} |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
sub print_doc { |
305
|
0
|
|
|
0
|
0
|
|
my ( $self, $filename ) = @_; |
306
|
|
|
|
|
|
|
|
307
|
0
|
|
|
|
|
|
my $p = $self->{pdf}; |
308
|
0
|
0
|
|
|
|
|
if ($filename) { |
309
|
0
|
|
|
|
|
|
open OUT, ">$filename"; |
310
|
0
|
|
|
|
|
|
print OUT $p->finish_report("none"); |
311
|
0
|
|
|
|
|
|
close OUT; |
312
|
|
|
|
|
|
|
} |
313
|
|
|
|
|
|
|
} |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
sub set_papersize { |
316
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
317
|
|
|
|
|
|
|
|
318
|
0
|
|
|
|
|
|
my $p = $self->{pdf}; |
319
|
0
|
|
|
|
|
|
my ( $pagewidth, $pageheigth ) = $p->get_pagedimensions(); |
320
|
0
|
|
|
|
|
|
$self->{paper} = { |
321
|
|
|
|
|
|
|
width => $pagewidth, |
322
|
|
|
|
|
|
|
topmargen => $pageheigth - 20, |
323
|
|
|
|
|
|
|
heigth => $self->{paper}{topmargen} |
324
|
|
|
|
|
|
|
}; |
325
|
|
|
|
|
|
|
} |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
sub out_text { |
328
|
0
|
|
|
0
|
0
|
|
my ( $self, $text, $x, $y, $align, $width ) = @_; |
329
|
|
|
|
|
|
|
|
330
|
0
|
|
|
|
|
|
my $p = $self->{pdf}; |
331
|
0
|
|
|
|
|
|
$x = mm_to_pt($x); |
332
|
|
|
|
|
|
|
## |
333
|
|
|
|
|
|
|
##print "$text er utf8\n" if utf8::is_utf8($text); |
334
|
|
|
|
|
|
|
##print "$text er ikke utf8\n" unless utf8::is_utf8($text); |
335
|
0
|
|
|
|
|
|
utf8::decode($text); |
336
|
0
|
0
|
|
|
|
|
utf8::decode($text) if utf8::is_utf8($text); |
337
|
0
|
|
|
|
|
|
my $sw = 0; |
338
|
0
|
0
|
|
|
|
|
$sw = int( $p->get_stringwidth($text) + .5 ) if lc($align) eq 'right'; |
339
|
0
|
|
|
|
|
|
$x -= $sw; |
340
|
0
|
|
|
|
|
|
my $margen = 20; |
341
|
0
|
|
0
|
|
|
|
$width ||= $self->{paper}{width} - $x - 20; |
342
|
0
|
|
|
|
|
|
my $linespace = $self->{font}{size} + 2; |
343
|
|
|
|
|
|
|
|
344
|
0
|
|
|
|
|
|
$p->add_paragraph( |
345
|
|
|
|
|
|
|
$text, $x, $y, |
346
|
|
|
|
|
|
|
$self->{paper}{width} - $x - 20, |
347
|
|
|
|
|
|
|
$self->{paper}{topmargen} - $y, |
348
|
|
|
|
|
|
|
0, $linespace |
349
|
|
|
|
|
|
|
); |
350
|
0
|
|
|
|
|
|
my ( $hPos, $vPos ) = $p->get_add_textpos(); |
351
|
0
|
0
|
|
|
|
|
$self->{ypos} = $vPos + $linespace if $self->{ypos} - $linespace > $vPos; |
352
|
|
|
|
|
|
|
} |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
sub mm_to_pt { |
355
|
0
|
|
|
0
|
0
|
|
my $mm = shift; |
356
|
|
|
|
|
|
|
|
357
|
0
|
|
|
|
|
|
return int( $mm / .3527777 ); |
358
|
|
|
|
|
|
|
} |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
1; |
361
|
|
|
|
|
|
|
__END__ |