|
Lines 210-215
sub draw_text {
Link Here
|
| 210 |
warn sprintf('No pdf object passed in.') and return -1 if !$pdf; |
210 |
warn sprintf('No pdf object passed in.') and return -1 if !$pdf; |
| 211 |
my @card_text = (); |
211 |
my @card_text = (); |
| 212 |
return unless (ref($self->{'layout'}->{'text'}) eq 'ARRAY'); # just in case there is not text |
212 |
return unless (ref($self->{'layout'}->{'text'}) eq 'ARRAY'); # just in case there is not text |
|
|
213 |
|
| 213 |
my $text = [@{$self->{'layout'}->{'text'}}]; # make a copy of the arrayref *not* simply a pointer |
214 |
my $text = [@{$self->{'layout'}->{'text'}}]; # make a copy of the arrayref *not* simply a pointer |
| 214 |
while (scalar @$text) { |
215 |
while (scalar @$text) { |
| 215 |
my $line = shift @$text; |
216 |
my $line = shift @$text; |
|
Lines 231-238
sub draw_text {
Link Here
|
| 231 |
$line = join(' ',@orig_line); |
232 |
$line = join(' ',@orig_line); |
| 232 |
} |
233 |
} |
| 233 |
my $text_attribs = shift @$text; |
234 |
my $text_attribs = shift @$text; |
| 234 |
my $origin_llx = $self->{'llx'} + $text_attribs->{'llx'}; |
235 |
my $origin_llx = $self->{'llx'} + $text_attribs->{'llx'} * $self->{'unitvalue'}; |
| 235 |
my $origin_lly = $self->{'lly'} + $text_attribs->{'lly'}; |
236 |
my $origin_lly = $self->{'lly'} + $text_attribs->{'lly'} * $self->{'unitvalue'}; |
| 236 |
my $Tx = 0; # final text llx |
237 |
my $Tx = 0; # final text llx |
| 237 |
my $Ty = $origin_lly; # final text lly |
238 |
my $Ty = $origin_lly; # final text lly |
| 238 |
my $Tw = 0; # final text word spacing. See http://www.adobe.com/devnet/pdf/pdf_reference.html ISO 32000-1 |
239 |
my $Tw = 0; # final text word spacing. See http://www.adobe.com/devnet/pdf/pdf_reference.html ISO 32000-1 |
|
Lines 270-277
sub draw_text {
Link Here
|
| 270 |
$string_width = C4::Creators::PDF->StrWidth($line, $text_attribs->{'font'}, $text_attribs->{'font_size'}); |
271 |
$string_width = C4::Creators::PDF->StrWidth($line, $text_attribs->{'font'}, $text_attribs->{'font_size'}); |
| 271 |
#$font_units_width = $m->string_width($line); |
272 |
#$font_units_width = $m->string_width($line); |
| 272 |
#$string_width = ($font_units_width * $text_attribs->{'font_size'}) / $units_per_em; |
273 |
#$string_width = ($font_units_width * $text_attribs->{'font_size'}) / $units_per_em; |
| 273 |
if (($string_width + $text_attribs->{'llx'}) < $self->{'width'}) { |
274 |
if ( $string_width + ( $text_attribs->{'llx'} * $self->{'unitvalue'} ) < $self->{'width'}) { |
| 274 |
($Tx, $Tw) = text_alignment($origin_llx, $self->{'width'}, $text_attribs->{'llx'}, $string_width, $line, $text_attribs->{'text_alignment'}); |
275 |
($Tx, $Tw) = text_alignment($origin_llx, $self->{'width'}, $text_attribs->{'llx'} * $self->{'unitvalue'}, $string_width, $line, $text_attribs->{'text_alignment'}); |
| 275 |
$line =~ s/^\s+//g; # strip naughty leading spaces |
276 |
$line =~ s/^\s+//g; # strip naughty leading spaces |
| 276 |
push @lines, {line=> $line, Tx => $Tx, Ty => $Ty, Tw => $Tw}; |
277 |
push @lines, {line=> $line, Tx => $Tx, Ty => $Ty, Tw => $Tw}; |
| 277 |
last WRAP_LINES; |
278 |
last WRAP_LINES; |
|
Lines 280-286
sub draw_text {
Link Here
|
| 280 |
} |
281 |
} |
| 281 |
} |
282 |
} |
| 282 |
else { |
283 |
else { |
| 283 |
($Tx, $Tw) = text_alignment($origin_llx, $self->{'width'}, $text_attribs->{'llx'}, $string_width, $line, $text_attribs->{'text_alignment'}); |
284 |
($Tx, $Tw) = text_alignment($origin_llx, $self->{'width'}, $text_attribs->{'llx'} * $self->{'unitvalue'}, $string_width, $line, $text_attribs->{'text_alignment'}); |
| 284 |
$line =~ s/^\s+//g; # strip naughty leading spaces |
285 |
$line =~ s/^\s+//g; # strip naughty leading spaces |
| 285 |
push @lines, {line=> $line, Tx => $Tx, Ty => $Ty, Tw => $Tw}; |
286 |
push @lines, {line=> $line, Tx => $Tx, Ty => $Ty, Tw => $Tw}; |
| 286 |
} |
287 |
} |
|
Lines 297-303
sub draw_text {
Link Here
|
| 297 |
else { |
298 |
else { |
| 298 |
$box_height += $text_attribs->{'font_size'}; |
299 |
$box_height += $text_attribs->{'font_size'}; |
| 299 |
} |
300 |
} |
| 300 |
box ($origin_llx, $box_lly, $self->{'width'} - $text_attribs->{'llx'}, $box_height, $pdf); |
301 |
box ($origin_llx, $box_lly, $self->{'width'} - ( $text_attribs->{'llx'} * $self->{'unitvalue'} ), $box_height, $pdf); |
| 301 |
} |
302 |
} |
| 302 |
$pdf->Font($text_attribs->{'font'}); |
303 |
$pdf->Font($text_attribs->{'font'}); |
| 303 |
$pdf->FontSize($text_attribs->{'font_size'}); |
304 |
$pdf->FontSize($text_attribs->{'font_size'}); |
|
Lines 315-325
sub draw_image {
Link Here
|
| 315 |
my ($self, $pdf) = @_; |
316 |
my ($self, $pdf) = @_; |
| 316 |
warn sprintf('No pdf object passed in.') and return -1 if !$pdf; |
317 |
warn sprintf('No pdf object passed in.') and return -1 if !$pdf; |
| 317 |
my $images = $self->{'layout'}->{'images'}; |
318 |
my $images = $self->{'layout'}->{'images'}; |
|
|
319 |
|
| 318 |
PROCESS_IMAGES: |
320 |
PROCESS_IMAGES: |
| 319 |
foreach my $image (keys %$images) { |
321 |
foreach my $image (keys %$images) { |
| 320 |
next PROCESS_IMAGES if $images->{$image}->{'data_source'}->[0]->{'image_source'} eq 'none'; |
322 |
next PROCESS_IMAGES if $images->{$image}->{'data_source'}->[0]->{'image_source'} eq 'none'; |
| 321 |
my $Tx = $self->{'llx'} + $images->{$image}->{'Tx'}; |
323 |
my $Tx = $self->{'llx'} + $images->{$image}->{'Tx'} * $self->{'unitvalue'}; |
| 322 |
my $Ty = $self->{'lly'} + $images->{$image}->{'Ty'}; |
324 |
my $Ty = $self->{'lly'} + $images->{$image}->{'Ty'} * $self->{'unitvalue'}; |
| 323 |
warn sprintf('No image passed in.') and next if !$images->{$image}->{'data'}; |
325 |
warn sprintf('No image passed in.') and next if !$images->{$image}->{'data'}; |
| 324 |
my $intName = $pdf->AltJpeg($images->{$image}->{'data'},$images->{$image}->{'Sx'}, $images->{$image}->{'Sy'}, 1, $images->{$image}->{'alt'}->{'data'},$images->{$image}->{'alt'}->{'Sx'}, $images->{$image}->{'alt'}->{'Sy'}, 1); |
326 |
my $intName = $pdf->AltJpeg($images->{$image}->{'data'},$images->{$image}->{'Sx'}, $images->{$image}->{'Sy'}, 1, $images->{$image}->{'alt'}->{'data'},$images->{$image}->{'alt'}->{'Sx'}, $images->{$image}->{'alt'}->{'Sy'}, 1); |
| 325 |
my $obj_stream = "q\n"; |
327 |
my $obj_stream = "q\n"; |
|
Lines 338-343
sub draw_image {
Link Here
|
| 338 |
sub _draw_barcode { # this is cut-and-paste from Label.pm because there is no common place for it atm... |
340 |
sub _draw_barcode { # this is cut-and-paste from Label.pm because there is no common place for it atm... |
| 339 |
my $self = shift; |
341 |
my $self = shift; |
| 340 |
my %params = @_; |
342 |
my %params = @_; |
|
|
343 |
|
| 341 |
my $x_scale_factor = 1; |
344 |
my $x_scale_factor = 1; |
| 342 |
my $num_of_chars = length($params{'barcode_data'}); |
345 |
my $num_of_chars = length($params{'barcode_data'}); |
| 343 |
my $tot_bar_length = 0; |
346 |
my $tot_bar_length = 0; |
|
Lines 357-364
sub _draw_barcode { # this is cut-and-paste from Label.pm because there is no
Link Here
|
| 357 |
} |
360 |
} |
| 358 |
eval { |
361 |
eval { |
| 359 |
PDF::Reuse::Barcode::Code39( |
362 |
PDF::Reuse::Barcode::Code39( |
| 360 |
x => $params{'llx'}, |
363 |
x => $params{'llx'} * $self->{'unitvalue'}, |
| 361 |
y => $params{'lly'}, |
364 |
y => $params{'lly'} * $self->{'unitvalue'}, |
| 362 |
value => "*$params{barcode_data}*", |
365 |
value => "*$params{barcode_data}*", |
| 363 |
xSize => $x_scale_factor, |
366 |
xSize => $x_scale_factor, |
| 364 |
ySize => $params{'y_scale_factor'}, |
367 |
ySize => $params{'y_scale_factor'}, |
|
Lines 377-384
sub _draw_barcode { # this is cut-and-paste from Label.pm because there is no
Link Here
|
| 377 |
$x_scale_factor = ($params{'width'} / $tot_bar_length) * 0.9; |
380 |
$x_scale_factor = ($params{'width'} / $tot_bar_length) * 0.9; |
| 378 |
eval { |
381 |
eval { |
| 379 |
PDF::Reuse::Barcode::COOP2of5( |
382 |
PDF::Reuse::Barcode::COOP2of5( |
| 380 |
x => $params{'llx'}, |
383 |
x => $params{'llx'}* $self->{'unitvalue'}, |
| 381 |
y => $params{'lly'}, |
384 |
y => $params{'lly'}* $self->{'unitvalue'}, |
| 382 |
value => "*$params{barcode_data}*", |
385 |
value => "*$params{barcode_data}*", |
| 383 |
xSize => $x_scale_factor, |
386 |
xSize => $x_scale_factor, |
| 384 |
ySize => $params{'y_scale_factor'}, |
387 |
ySize => $params{'y_scale_factor'}, |
|
Lines 395-402
sub _draw_barcode { # this is cut-and-paste from Label.pm because there is no
Link Here
|
| 395 |
$x_scale_factor = ($params{'width'} / $tot_bar_length) * 0.9; |
398 |
$x_scale_factor = ($params{'width'} / $tot_bar_length) * 0.9; |
| 396 |
eval { |
399 |
eval { |
| 397 |
PDF::Reuse::Barcode::Industrial2of5( |
400 |
PDF::Reuse::Barcode::Industrial2of5( |
| 398 |
x => $params{'llx'}, |
401 |
x => $params{'llx'}* $self->{'unitvalue'} , |
| 399 |
y => $params{'lly'}, |
402 |
y => $params{'lly'}* $self->{'unitvalue'}, |
| 400 |
value => "*$params{barcode_data}*", |
403 |
value => "*$params{barcode_data}*", |
| 401 |
xSize => $x_scale_factor, |
404 |
xSize => $x_scale_factor, |
| 402 |
ySize => $params{'y_scale_factor'}, |
405 |
ySize => $params{'y_scale_factor'}, |
| 403 |
- |
|
|