View | Details | Raw Unified | Return to bug 18550
Collapse All | Expand All

(-)a/C4/Patroncards/Patroncard.pm (-15 / +17 lines)
Lines 171-176 sub draw_text { Link Here
171
    warn sprintf('No pdf object passed in.') and return -1 if !$pdf;
171
    warn sprintf('No pdf object passed in.') and return -1 if !$pdf;
172
    my @card_text = ();
172
    my @card_text = ();
173
    return unless (ref($self->{'layout'}->{'text'}) eq 'ARRAY'); # just in case there is not text
173
    return unless (ref($self->{'layout'}->{'text'}) eq 'ARRAY'); # just in case there is not text
174
174
    my $text = [@{$self->{'layout'}->{'text'}}]; # make a copy of the arrayref *not* simply a pointer
175
    my $text = [@{$self->{'layout'}->{'text'}}]; # make a copy of the arrayref *not* simply a pointer
175
    while (scalar @$text) {
176
    while (scalar @$text) {
176
        my $line = shift @$text;
177
        my $line = shift @$text;
Lines 192-199 sub draw_text { Link Here
192
            $line = join(' ',@orig_line);
193
            $line = join(' ',@orig_line);
193
        }
194
        }
194
        my $text_attribs = shift @$text;
195
        my $text_attribs = shift @$text;
195
        my $origin_llx = $self->{'llx'} + $text_attribs->{'llx'};
196
        my $origin_llx = $self->{'llx'} + $text_attribs->{'llx'} * $self->{'unitvalue'};
196
        my $origin_lly = $self->{'lly'} + $text_attribs->{'lly'};
197
        my $origin_lly = $self->{'lly'} + $text_attribs->{'lly'} * $self->{'unitvalue'};
197
        my $Tx = 0;     # final text llx
198
        my $Tx = 0;     # final text llx
198
        my $Ty = $origin_lly;   # final text lly
199
        my $Ty = $origin_lly;   # final text lly
199
        my $Tw = 0;     # final text word spacing. See http://www.adobe.com/devnet/pdf/pdf_reference.html ISO 32000-1
200
        my $Tw = 0;     # final text word spacing. See http://www.adobe.com/devnet/pdf/pdf_reference.html ISO 32000-1
Lines 231-238 sub draw_text { Link Here
231
                    $string_width = C4::Creators::PDF->StrWidth($line, $text_attribs->{'font'}, $text_attribs->{'font_size'});
232
                    $string_width = C4::Creators::PDF->StrWidth($line, $text_attribs->{'font'}, $text_attribs->{'font_size'});
232
                    #$font_units_width = $m->string_width($line);
233
                    #$font_units_width = $m->string_width($line);
233
                    #$string_width = ($font_units_width * $text_attribs->{'font_size'}) / $units_per_em;
234
                    #$string_width = ($font_units_width * $text_attribs->{'font_size'}) / $units_per_em;
234
                    if (($string_width + $text_attribs->{'llx'}) < $self->{'width'}) {
235
                    if ( $string_width + ( $text_attribs->{'llx'} * $self->{'unitvalue'} ) < $self->{'width'}) {
235
                        ($Tx, $Tw) = text_alignment($origin_llx, $self->{'width'}, $text_attribs->{'llx'}, $string_width, $line, $text_attribs->{'text_alignment'});
236
                        ($Tx, $Tw) = text_alignment($origin_llx, $self->{'width'}, $text_attribs->{'llx'} * $self->{'unitvalue'}, $string_width, $line, $text_attribs->{'text_alignment'});
236
                        $line =~ s/^\s+//g;     # strip naughty leading spaces
237
                        $line =~ s/^\s+//g;     # strip naughty leading spaces
237
                        push @lines, {line=> $line, Tx => $Tx, Ty => $Ty, Tw => $Tw};
238
                        push @lines, {line=> $line, Tx => $Tx, Ty => $Ty, Tw => $Tw};
238
                        last WRAP_LINES;
239
                        last WRAP_LINES;
Lines 241-247 sub draw_text { Link Here
241
            }
242
            }
242
        }
243
        }
243
        else {
244
        else {
244
            ($Tx, $Tw) = text_alignment($origin_llx, $self->{'width'}, $text_attribs->{'llx'}, $string_width, $line, $text_attribs->{'text_alignment'});
245
            ($Tx, $Tw) = text_alignment($origin_llx, $self->{'width'}, $text_attribs->{'llx'} * $self->{'unitvalue'}, $string_width, $line, $text_attribs->{'text_alignment'});
245
            $line =~ s/^\s+//g;     # strip naughty leading spaces
246
            $line =~ s/^\s+//g;     # strip naughty leading spaces
246
            push @lines, {line=> $line, Tx => $Tx, Ty => $Ty, Tw => $Tw};
247
            push @lines, {line=> $line, Tx => $Tx, Ty => $Ty, Tw => $Tw};
247
        }
248
        }
Lines 258-264 sub draw_text { Link Here
258
            else {
259
            else {
259
                $box_height += $text_attribs->{'font_size'};
260
                $box_height += $text_attribs->{'font_size'};
260
            }
261
            }
261
            box ($origin_llx, $box_lly, $self->{'width'} - $text_attribs->{'llx'}, $box_height, $pdf);
262
            box ($origin_llx, $box_lly, $self->{'width'} - ( $text_attribs->{'llx'} * $self->{'unitvalue'} ), $box_height, $pdf);
262
        }
263
        }
263
        $pdf->Font($text_attribs->{'font'});
264
        $pdf->Font($text_attribs->{'font'});
264
        $pdf->FontSize($text_attribs->{'font_size'});
265
        $pdf->FontSize($text_attribs->{'font_size'});
Lines 272-282 sub draw_image { Link Here
272
    my ($self, $pdf) = @_;
273
    my ($self, $pdf) = @_;
273
    warn sprintf('No pdf object passed in.') and return -1 if !$pdf;
274
    warn sprintf('No pdf object passed in.') and return -1 if !$pdf;
274
    my $images = $self->{'layout'}->{'images'};
275
    my $images = $self->{'layout'}->{'images'};
276
275
    PROCESS_IMAGES:
277
    PROCESS_IMAGES:
276
    foreach my $image (keys %$images) {
278
    foreach my $image (keys %$images) {
277
        next PROCESS_IMAGES if $images->{$image}->{'data_source'}->[0]->{'image_source'} eq 'none';
279
        next PROCESS_IMAGES if $images->{$image}->{'data_source'}->[0]->{'image_source'} eq 'none';
278
        my $Tx = $self->{'llx'} + $images->{$image}->{'Tx'};
280
        my $Tx = $self->{'llx'} + $images->{$image}->{'Tx'} * $self->{'unitvalue'};
279
        my $Ty = $self->{'lly'} + $images->{$image}->{'Ty'};
281
        my $Ty = $self->{'lly'} + $images->{$image}->{'Ty'} * $self->{'unitvalue'};
280
        warn sprintf('No image passed in.') and next if !$images->{$image}->{'data'};
282
        warn sprintf('No image passed in.') and next if !$images->{$image}->{'data'};
281
        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);
283
        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);
282
        my $obj_stream = "q\n";
284
        my $obj_stream = "q\n";
Lines 291-296 sub draw_image { Link Here
291
sub _draw_barcode {   # this is cut-and-paste from Label.pm because there is no common place for it atm...
293
sub _draw_barcode {   # this is cut-and-paste from Label.pm because there is no common place for it atm...
292
    my $self = shift;
294
    my $self = shift;
293
    my %params = @_;
295
    my %params = @_;
296
294
    my $x_scale_factor = 1;
297
    my $x_scale_factor = 1;
295
    my $num_of_chars = length($params{'barcode_data'});
298
    my $num_of_chars = length($params{'barcode_data'});
296
    my $tot_bar_length = 0;
299
    my $tot_bar_length = 0;
Lines 310-317 sub _draw_barcode { # this is cut-and-paste from Label.pm because there is no Link Here
310
        }
313
        }
311
        eval {
314
        eval {
312
            PDF::Reuse::Barcode::Code39(
315
            PDF::Reuse::Barcode::Code39(
313
                x                   => $params{'llx'},
316
                x                   => $params{'llx'} * $self->{'unitvalue'},
314
                y                   => $params{'lly'},
317
                y                   => $params{'lly'} * $self->{'unitvalue'},
315
                value               => "*$params{barcode_data}*",
318
                value               => "*$params{barcode_data}*",
316
                xSize               => $x_scale_factor,
319
                xSize               => $x_scale_factor,
317
                ySize               => $params{'y_scale_factor'},
320
                ySize               => $params{'y_scale_factor'},
Lines 330-337 sub _draw_barcode { # this is cut-and-paste from Label.pm because there is no Link Here
330
        $x_scale_factor = ($params{'width'} / $tot_bar_length) * 0.9;
333
        $x_scale_factor = ($params{'width'} / $tot_bar_length) * 0.9;
331
        eval {
334
        eval {
332
            PDF::Reuse::Barcode::COOP2of5(
335
            PDF::Reuse::Barcode::COOP2of5(
333
                x                   => $params{'llx'},
336
                x                   => $params{'llx'}* $self->{'unitvalue'},
334
                y                   => $params{'lly'},
337
                y                   => $params{'lly'}* $self->{'unitvalue'},
335
                value               => "*$params{barcode_data}*",
338
                value               => "*$params{barcode_data}*",
336
                xSize               => $x_scale_factor,
339
                xSize               => $x_scale_factor,
337
                ySize               => $params{'y_scale_factor'},
340
                ySize               => $params{'y_scale_factor'},
Lines 348-355 sub _draw_barcode { # this is cut-and-paste from Label.pm because there is no Link Here
348
        $x_scale_factor = ($params{'width'} / $tot_bar_length) * 0.9;
351
        $x_scale_factor = ($params{'width'} / $tot_bar_length) * 0.9;
349
        eval {
352
        eval {
350
            PDF::Reuse::Barcode::Industrial2of5(
353
            PDF::Reuse::Barcode::Industrial2of5(
351
                x                   => $params{'llx'},
354
                x                   => $params{'llx'}* $self->{'unitvalue'} ,
352
                y                   => $params{'lly'},
355
                y                   => $params{'lly'}* $self->{'unitvalue'},
353
                value               => "*$params{barcode_data}*",
356
                value               => "*$params{barcode_data}*",
354
                xSize               => $x_scale_factor,
357
                xSize               => $x_scale_factor,
355
                ySize               => $params{'y_scale_factor'},
358
                ySize               => $params{'y_scale_factor'},
356
- 

Return to bug 18550