Lines 166-171
sub draw_text {
Link Here
|
166 |
warn sprintf('No pdf object passed in.') and return -1 if !$pdf; |
166 |
warn sprintf('No pdf object passed in.') and return -1 if !$pdf; |
167 |
my @card_text = (); |
167 |
my @card_text = (); |
168 |
return unless (ref($self->{'layout'}->{'text'}) eq 'ARRAY'); # just in case there is not text |
168 |
return unless (ref($self->{'layout'}->{'text'}) eq 'ARRAY'); # just in case there is not text |
|
|
169 |
|
170 |
my $units = get_unit_values(); |
171 |
my $unitvalue = 1; |
172 |
foreach my $un (@$units){ |
173 |
if ($un->{'type'} eq $self->{'layout'}->{'units'}) { |
174 |
$unitvalue = $un->{'value'}; |
175 |
} |
176 |
} |
177 |
|
178 |
|
169 |
my $text = [@{$self->{'layout'}->{'text'}}]; # make a copy of the arrayref *not* simply a pointer |
179 |
my $text = [@{$self->{'layout'}->{'text'}}]; # make a copy of the arrayref *not* simply a pointer |
170 |
while (scalar @$text) { |
180 |
while (scalar @$text) { |
171 |
my $line = shift @$text; |
181 |
my $line = shift @$text; |
Lines 187-194
sub draw_text {
Link Here
|
187 |
$line = join(' ',@orig_line); |
197 |
$line = join(' ',@orig_line); |
188 |
} |
198 |
} |
189 |
my $text_attribs = shift @$text; |
199 |
my $text_attribs = shift @$text; |
190 |
my $origin_llx = $self->{'llx'} + $text_attribs->{'llx'}; |
200 |
my $origin_llx = $self->{'llx'} + $text_attribs->{'llx'} * $unitvalue; |
191 |
my $origin_lly = $self->{'lly'} + $text_attribs->{'lly'}; |
201 |
my $origin_lly = $self->{'lly'} + $text_attribs->{'lly'} * $unitvalue; |
192 |
my $Tx = 0; # final text llx |
202 |
my $Tx = 0; # final text llx |
193 |
my $Ty = $origin_lly; # final text lly |
203 |
my $Ty = $origin_lly; # final text lly |
194 |
my $Tw = 0; # final text word spacing. See http://www.adobe.com/devnet/pdf/pdf_reference.html ISO 32000-1 |
204 |
my $Tw = 0; # final text word spacing. See http://www.adobe.com/devnet/pdf/pdf_reference.html ISO 32000-1 |
Lines 226-233
sub draw_text {
Link Here
|
226 |
$string_width = C4::Creators::PDF->StrWidth($line, $text_attribs->{'font'}, $text_attribs->{'font_size'}); |
236 |
$string_width = C4::Creators::PDF->StrWidth($line, $text_attribs->{'font'}, $text_attribs->{'font_size'}); |
227 |
#$font_units_width = $m->string_width($line); |
237 |
#$font_units_width = $m->string_width($line); |
228 |
#$string_width = ($font_units_width * $text_attribs->{'font_size'}) / $units_per_em; |
238 |
#$string_width = ($font_units_width * $text_attribs->{'font_size'}) / $units_per_em; |
229 |
if (($string_width + $text_attribs->{'llx'}) < $self->{'width'}) { |
239 |
if ( $string_width + ( $text_attribs->{'llx'} * $unitvalue ) < $self->{'width'}) { |
230 |
($Tx, $Tw) = text_alignment($origin_llx, $self->{'width'}, $text_attribs->{'llx'}, $string_width, $line, $text_attribs->{'text_alignment'}); |
240 |
($Tx, $Tw) = text_alignment($origin_llx, $self->{'width'}, $text_attribs->{'llx'} * $unitvalue, $string_width, $line, $text_attribs->{'text_alignment'}); |
231 |
$line =~ s/^\s+//g; # strip naughty leading spaces |
241 |
$line =~ s/^\s+//g; # strip naughty leading spaces |
232 |
push @lines, {line=> $line, Tx => $Tx, Ty => $Ty, Tw => $Tw}; |
242 |
push @lines, {line=> $line, Tx => $Tx, Ty => $Ty, Tw => $Tw}; |
233 |
last WRAP_LINES; |
243 |
last WRAP_LINES; |
Lines 236-242
sub draw_text {
Link Here
|
236 |
} |
246 |
} |
237 |
} |
247 |
} |
238 |
else { |
248 |
else { |
239 |
($Tx, $Tw) = text_alignment($origin_llx, $self->{'width'}, $text_attribs->{'llx'}, $string_width, $line, $text_attribs->{'text_alignment'}); |
249 |
($Tx, $Tw) = text_alignment($origin_llx, $self->{'width'}, $text_attribs->{'llx'} * $unitvalue, $string_width, $line, $text_attribs->{'text_alignment'}); |
240 |
$line =~ s/^\s+//g; # strip naughty leading spaces |
250 |
$line =~ s/^\s+//g; # strip naughty leading spaces |
241 |
push @lines, {line=> $line, Tx => $Tx, Ty => $Ty, Tw => $Tw}; |
251 |
push @lines, {line=> $line, Tx => $Tx, Ty => $Ty, Tw => $Tw}; |
242 |
} |
252 |
} |
Lines 253-259
sub draw_text {
Link Here
|
253 |
else { |
263 |
else { |
254 |
$box_height += $text_attribs->{'font_size'}; |
264 |
$box_height += $text_attribs->{'font_size'}; |
255 |
} |
265 |
} |
256 |
box ($origin_llx, $box_lly, $self->{'width'} - $text_attribs->{'llx'}, $box_height, $pdf); |
266 |
box ($origin_llx, $box_lly, $self->{'width'} - ( $text_attribs->{'llx'} * $unitvalue ), $box_height, $pdf); |
257 |
} |
267 |
} |
258 |
$pdf->Font($text_attribs->{'font'}); |
268 |
$pdf->Font($text_attribs->{'font'}); |
259 |
$pdf->FontSize($text_attribs->{'font_size'}); |
269 |
$pdf->FontSize($text_attribs->{'font_size'}); |
Lines 267-277
sub draw_image {
Link Here
|
267 |
my ($self, $pdf) = @_; |
277 |
my ($self, $pdf) = @_; |
268 |
warn sprintf('No pdf object passed in.') and return -1 if !$pdf; |
278 |
warn sprintf('No pdf object passed in.') and return -1 if !$pdf; |
269 |
my $images = $self->{'layout'}->{'images'}; |
279 |
my $images = $self->{'layout'}->{'images'}; |
|
|
280 |
|
281 |
my $units = get_unit_values(); |
282 |
my $unitvalue = 1; |
283 |
foreach my $un (@$units){ |
284 |
if ($un->{'type'} eq $self->{'layout'}->{'units'}) { |
285 |
$unitvalue = $un->{'value'}; |
286 |
} |
287 |
} |
288 |
|
270 |
PROCESS_IMAGES: |
289 |
PROCESS_IMAGES: |
271 |
foreach my $image (keys %$images) { |
290 |
foreach my $image (keys %$images) { |
272 |
next PROCESS_IMAGES if $images->{$image}->{'data_source'}->[0]->{'image_source'} eq 'none'; |
291 |
next PROCESS_IMAGES if $images->{$image}->{'data_source'}->[0]->{'image_source'} eq 'none'; |
273 |
my $Tx = $self->{'llx'} + $images->{$image}->{'Tx'}; |
292 |
my $Tx = $self->{'llx'} + $images->{$image}->{'Tx'} * $unitvalue; |
274 |
my $Ty = $self->{'lly'} + $images->{$image}->{'Ty'}; |
293 |
my $Ty = $self->{'lly'} + $images->{$image}->{'Ty'} * $unitvalue; |
275 |
warn sprintf('No image passed in.') and next if !$images->{$image}->{'data'}; |
294 |
warn sprintf('No image passed in.') and next if !$images->{$image}->{'data'}; |
276 |
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); |
295 |
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); |
277 |
my $obj_stream = "q\n"; |
296 |
my $obj_stream = "q\n"; |
Lines 286-291
sub draw_image {
Link Here
|
286 |
sub _draw_barcode { # this is cut-and-paste from Label.pm because there is no common place for it atm... |
305 |
sub _draw_barcode { # this is cut-and-paste from Label.pm because there is no common place for it atm... |
287 |
my $self = shift; |
306 |
my $self = shift; |
288 |
my %params = @_; |
307 |
my %params = @_; |
|
|
308 |
|
309 |
my $units = get_unit_values(); |
310 |
my $unitvalue = 1; |
311 |
foreach my $un (@$units){ |
312 |
if ($un->{'type'} eq $self->{'layout'}->{'units'}) { |
313 |
$unitvalue = $un->{'value'}; |
314 |
} |
315 |
} |
316 |
|
289 |
my $x_scale_factor = 1; |
317 |
my $x_scale_factor = 1; |
290 |
my $num_of_chars = length($params{'barcode_data'}); |
318 |
my $num_of_chars = length($params{'barcode_data'}); |
291 |
my $tot_bar_length = 0; |
319 |
my $tot_bar_length = 0; |
Lines 305-312
sub _draw_barcode { # this is cut-and-paste from Label.pm because there is no
Link Here
|
305 |
} |
333 |
} |
306 |
eval { |
334 |
eval { |
307 |
PDF::Reuse::Barcode::Code39( |
335 |
PDF::Reuse::Barcode::Code39( |
308 |
x => $params{'llx'}, |
336 |
x => $params{'llx'} * $unitvalue, |
309 |
y => $params{'lly'}, |
337 |
y => $params{'lly'} * $unitvalue, |
310 |
value => "*$params{barcode_data}*", |
338 |
value => "*$params{barcode_data}*", |
311 |
xSize => $x_scale_factor, |
339 |
xSize => $x_scale_factor, |
312 |
ySize => $params{'y_scale_factor'}, |
340 |
ySize => $params{'y_scale_factor'}, |
Lines 325-332
sub _draw_barcode { # this is cut-and-paste from Label.pm because there is no
Link Here
|
325 |
$x_scale_factor = ($params{'width'} / $tot_bar_length) * 0.9; |
353 |
$x_scale_factor = ($params{'width'} / $tot_bar_length) * 0.9; |
326 |
eval { |
354 |
eval { |
327 |
PDF::Reuse::Barcode::COOP2of5( |
355 |
PDF::Reuse::Barcode::COOP2of5( |
328 |
x => $params{'llx'}, |
356 |
x => $params{'llx'}* $unitvalue, |
329 |
y => $params{'lly'}, |
357 |
y => $params{'lly'}* $unitvalue, |
330 |
value => "*$params{barcode_data}*", |
358 |
value => "*$params{barcode_data}*", |
331 |
xSize => $x_scale_factor, |
359 |
xSize => $x_scale_factor, |
332 |
ySize => $params{'y_scale_factor'}, |
360 |
ySize => $params{'y_scale_factor'}, |
Lines 343-350
sub _draw_barcode { # this is cut-and-paste from Label.pm because there is no
Link Here
|
343 |
$x_scale_factor = ($params{'width'} / $tot_bar_length) * 0.9; |
371 |
$x_scale_factor = ($params{'width'} / $tot_bar_length) * 0.9; |
344 |
eval { |
372 |
eval { |
345 |
PDF::Reuse::Barcode::Industrial2of5( |
373 |
PDF::Reuse::Barcode::Industrial2of5( |
346 |
x => $params{'llx'}, |
374 |
x => $params{'llx'}* $unitvalue, |
347 |
y => $params{'lly'}, |
375 |
y => $params{'lly'}* $unitvalue, |
348 |
value => "*$params{barcode_data}*", |
376 |
value => "*$params{barcode_data}*", |
349 |
xSize => $x_scale_factor, |
377 |
xSize => $x_scale_factor, |
350 |
ySize => $params{'y_scale_factor'}, |
378 |
ySize => $params{'y_scale_factor'}, |
351 |
- |
|
|