Lines 91-109
sub new {
Link Here
|
91 |
=cut |
91 |
=cut |
92 |
|
92 |
|
93 |
sub draw_barcode { |
93 |
sub draw_barcode { |
94 |
my ($self, $pdf) = @_; |
94 |
my ( $self, $pdf ) = @_; |
|
|
95 |
|
95 |
# Default values for barcode scaling are set in constructor to work with pre-existing installations |
96 |
# Default values for barcode scaling are set in constructor to work with pre-existing installations |
96 |
my $barcode_height_scale = $self->{'barcode_height_scale'}; |
97 |
my $barcode_height_scale = $self->{'barcode_height_scale'}; |
97 |
my $barcode_width_scale = $self->{'barcode_width_scale'}; |
98 |
my $barcode_width_scale = $self->{'barcode_width_scale'}; |
98 |
|
99 |
my $llx = $self->{'llx'} || 0; |
99 |
_draw_barcode( $self, |
100 |
my $llx_layout = $self->{'layout'}->{'barcode'}->[0]->{'llx'} || 0; |
100 |
llx => $self->{'llx'} + $self->{'layout'}->{'barcode'}->[0]->{'llx'} * $self->{'unitvalue'}, |
101 |
my $lly = $self->{'lly'} || 0; |
101 |
lly => $self->{'lly'} + $self->{'layout'}->{'barcode'}->[0]->{'lly'} * $self->{'unitvalue'}, |
102 |
my $lly_layout = $self->{'layout'}->{'barcode'}->[0]->{'lly'} || 0; |
102 |
width => $self->{'width'} * $barcode_width_scale, |
103 |
_draw_barcode( |
103 |
y_scale_factor => $self->{'height'} * $barcode_height_scale, |
104 |
$self, |
104 |
barcode_type => $self->{'layout'}->{'barcode'}->[0]->{'type'}, |
105 |
llx => $llx + $llx_layout * $self->{'unitvalue'}, |
105 |
barcode_data => $self->{'layout'}->{'barcode'}->[0]->{'data'}, |
106 |
lly => $lly + $lly_layout * $self->{'unitvalue'}, |
106 |
text => $self->{'layout'}->{'barcode'}->[0]->{'text_print'}, |
107 |
width => $self->{'width'} * $barcode_width_scale, |
|
|
108 |
y_scale_factor => $self->{'height'} * $barcode_height_scale, |
109 |
barcode_type => $self->{'layout'}->{'barcode'}->[0]->{'type'}, |
110 |
barcode_data => $self->{'layout'}->{'barcode'}->[0]->{'data'}, |
111 |
text => $self->{'layout'}->{'barcode'}->[0]->{'text_print'}, |
107 |
); |
112 |
); |
108 |
} |
113 |
} |
109 |
|
114 |
|
Lines 241-249
sub draw_text {
Link Here
|
241 |
} @orig_line; |
246 |
} @orig_line; |
242 |
$line = join(' ',@orig_line); |
247 |
$line = join(' ',@orig_line); |
243 |
} |
248 |
} |
244 |
my $text_attribs = shift @$text; |
249 |
my $text_attribs = shift @$text; |
245 |
my $origin_llx = $self->{'llx'} + $text_attribs->{'llx'} * $self->{'unitvalue'}; |
250 |
my $llx = $self->{'llx'} || 0; |
246 |
my $origin_lly = $self->{'lly'} + $text_attribs->{'lly'} * $self->{'unitvalue'}; |
251 |
my $llx_text_attr = $text_attribs->{'llx'} || 0; |
|
|
252 |
my $lly = $self->{'lly'} || 0; |
253 |
my $lly_text_attr = $text_attribs->{'lly'} || 0; |
254 |
|
255 |
my $origin_llx = $llx + $llx_text_attr * $self->{'unitvalue'}; |
256 |
my $origin_lly = $lly + $lly_text_attr * $self->{'unitvalue'}; |
247 |
my $Tx = 0; # final text llx |
257 |
my $Tx = 0; # final text llx |
248 |
my $Ty = $origin_lly; # final text lly |
258 |
my $Ty = $origin_lly; # final text lly |
249 |
my $Tw = 0; # final text word spacing. See http://www.adobe.com/devnet/pdf/pdf_reference.html ISO 32000-1 |
259 |
my $Tw = 0; # final text word spacing. See http://www.adobe.com/devnet/pdf/pdf_reference.html ISO 32000-1 |
Lines 258-289
sub draw_text {
Link Here
|
258 |
# my $units_per_em = $m->get_units_per_em(); |
268 |
# my $units_per_em = $m->get_units_per_em(); |
259 |
# my $font_units_width = $m->string_width($line); |
269 |
# my $font_units_width = $m->string_width($line); |
260 |
# my $string_width = ($font_units_width * $text_attribs->{'font_size'}) / $units_per_em; |
270 |
# my $string_width = ($font_units_width * $text_attribs->{'font_size'}) / $units_per_em; |
261 |
my $string_width = C4::Creators::PDF->StrWidth($line, $text_attribs->{'font'}, $text_attribs->{'font_size'}); |
271 |
## Please see file perltidy.ERR |
262 |
if (($string_width + $text_attribs->{'llx'}) > $self->{'width'}) { |
272 |
my $string_width = C4::Creators::PDF->StrWidth( $line, $text_attribs->{'font'}, $text_attribs->{'font_size'} ); |
|
|
273 |
if ( ( $string_width + $llx_text_attr ) > $self->{'width'} ) { |
263 |
my $cur_line = ""; |
274 |
my $cur_line = ""; |
264 |
WRAP_LINES: |
275 |
WRAP_LINES: |
265 |
while (1) { |
276 |
while (1) { |
266 |
# $line =~ m/^.*(\s\b.*\b\s*|\s&|\<\b.*\b\>)$/; # original regexp... can be removed after dev stage is over |
277 |
|
|
|
278 |
# $line =~ m/^.*(\s\b.*\b\s*|\s&|\<\b.*\b\>)$/; # original regexp... can be removed after dev stage is over |
267 |
$line =~ m/^.*(\s.*\s*|\s&|\<.*\>)$/; |
279 |
$line =~ m/^.*(\s.*\s*|\s&|\<.*\>)$/; |
268 |
$trim = $1 . $trim; |
280 |
$trim = $1 . $trim; |
|
|
281 |
|
269 |
#Sanitize the input into this regular expression so regex metacharacters are escaped as literal values (https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22429) |
282 |
#Sanitize the input into this regular expression so regex metacharacters are escaped as literal values (https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22429) |
270 |
$line =~ s/\Q$1\E$//; |
283 |
$line =~ s/\Q$1\E$//; |
271 |
$string_width = C4::Creators::PDF->StrWidth($line, $text_attribs->{'font'}, $text_attribs->{'font_size'}); |
284 |
$string_width = |
272 |
# $font_units_width = $m->string_width($line); |
285 |
C4::Creators::PDF->StrWidth( $line, $text_attribs->{'font'}, $text_attribs->{'font_size'} ); |
273 |
# $string_width = ($font_units_width * $text_attribs->{'font_size'}) / $units_per_em; |
286 |
|
274 |
if (($string_width + $text_attribs->{'llx'}) < $self->{'width'}) { |
287 |
# $font_units_width = $m->string_width($line); |
275 |
($Tx, $Tw) = text_alignment($origin_llx, $self->{'width'}, $text_attribs->{'llx'}, $string_width, $line, $text_attribs->{'text_alignment'}); |
288 |
# $string_width = ($font_units_width * $text_attribs->{'font_size'}) / $units_per_em; |
276 |
push @lines, {line=> $line, Tx => $Tx, Ty => $Ty, Tw => $Tw}; |
289 |
if ( ( $string_width + $text_attribs->{'llx'} ) < $self->{'width'} ) { |
|
|
290 |
( $Tx, $Tw ) = text_alignment( |
291 |
$origin_llx, $self->{'width'}, $text_attribs->{'llx'}, $string_width, $line, |
292 |
$text_attribs->{'text_alignment'} |
293 |
); |
294 |
push @lines, { line => $line, Tx => $Tx, Ty => $Ty, Tw => $Tw }; |
277 |
$line = undef; |
295 |
$line = undef; |
278 |
last WRAP_LINES if $trim eq ''; |
296 |
last WRAP_LINES if $trim eq ''; |
279 |
$Ty -= leading($text_attribs->{'font_size'}); |
297 |
$Ty -= leading( $text_attribs->{'font_size'} ); |
280 |
$line = $trim; |
298 |
$line = $trim; |
281 |
$trim = ''; |
299 |
$trim = ''; |
282 |
$string_width = C4::Creators::PDF->StrWidth($line, $text_attribs->{'font'}, $text_attribs->{'font_size'}); |
300 |
$string_width = |
|
|
301 |
C4::Creators::PDF->StrWidth( $line, $text_attribs->{'font'}, $text_attribs->{'font_size'} ); |
302 |
|
283 |
#$font_units_width = $m->string_width($line); |
303 |
#$font_units_width = $m->string_width($line); |
284 |
#$string_width = ($font_units_width * $text_attribs->{'font_size'}) / $units_per_em; |
304 |
#$string_width = ($font_units_width * $text_attribs->{'font_size'}) / $units_per_em; |
285 |
if ( $string_width + ( $text_attribs->{'llx'} * $self->{'unitvalue'} ) < $self->{'width'}) { |
305 |
if ( $string_width + ( $text_attribs->{'llx'} * $self->{'unitvalue'} ) < $self->{'width'} ) { |
286 |
($Tx, $Tw) = text_alignment($origin_llx, $self->{'width'}, $text_attribs->{'llx'} * $self->{'unitvalue'}, $string_width, $line, $text_attribs->{'text_alignment'}); |
306 |
( $Tx, $Tw ) = text_alignment( |
|
|
307 |
$origin_llx, $self->{'width'}, |
308 |
$text_attribs->{'llx'} * $self->{'unitvalue'}, $string_width, $line, |
309 |
$text_attribs->{'text_alignment'} |
310 |
); |
287 |
$line =~ s/^\s+//g; # strip naughty leading spaces |
311 |
$line =~ s/^\s+//g; # strip naughty leading spaces |
288 |
push @lines, {line=> $line, Tx => $Tx, Ty => $Ty, Tw => $Tw}; |
312 |
push @lines, {line=> $line, Tx => $Tx, Ty => $Ty, Tw => $Tw}; |
289 |
last WRAP_LINES; |
313 |
last WRAP_LINES; |
Lines 298-304
sub draw_text {
Link Here
|
298 |
} |
322 |
} |
299 |
} |
323 |
} |
300 |
else { |
324 |
else { |
301 |
($Tx, $Tw) = text_alignment($origin_llx, $self->{'width'}, $text_attribs->{'llx'} * $self->{'unitvalue'}, $string_width, $line, $text_attribs->{'text_alignment'}); |
325 |
($Tx, $Tw) = text_alignment($origin_llx, $self->{'width'}, $lly_text_attr * $self->{'unitvalue'}, $string_width, $line, $text_attribs->{'text_alignment'}); |
302 |
$line =~ s/^\s+//g; # strip naughty leading spaces |
326 |
$line =~ s/^\s+//g; # strip naughty leading spaces |
303 |
push @lines, {line=> $line, Tx => $Tx, Ty => $Ty, Tw => $Tw}; |
327 |
push @lines, {line=> $line, Tx => $Tx, Ty => $Ty, Tw => $Tw}; |
304 |
} |
328 |
} |
305 |
- |
|
|