Bugzilla – Attachment 63219 Details for
Bug 18550
Patron card creator: Print output does not respect layout units
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18550 - Patron card creator: Print output does not respect layout units
Bug-18550---Patron-card-creator-Print-output-does-.patch (text/plain), 7.54 KB, created by
Marc Véron
on 2017-05-07 09:54:35 UTC
(
hide
)
Description:
Bug 18550 - Patron card creator: Print output does not respect layout units
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2017-05-07 09:54:35 UTC
Size:
7.54 KB
patch
obsolete
>From 820af45e158a7a2f54f0e94fdb65168fe3e4f741 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Marc=20V=C3=A9ron?= <veron@veron.ch> >Date: Fri, 5 May 2017 15:08:56 +0200 >Subject: [PATCH] Bug 18550 - Patron card creator: Print output does not > respect layout units > >To reproduce: >Text, images and barcode positions are always layed out based on PostScript points, regardless of unit defined in card layout. > >To reproduce: >- Test on top of Bug 18541 (introduces layout grid) >- Create a card layout with a text field, an image and a barcode. Use points > as layout unit >- Activate layout grid >- Create PDF output, save >- Change layout unit to mm >- Create PDF output, save >- Compare PDFs. Verify that the positions are unchanged (still using points) > >To test: >- Apply patch >- Create again PDF >- Verify that elements are positionad as expected (using unit, e.g. mm) >- Bonus test: Repeat with other units >--- > C4/Patroncards/Patroncard.pm | 31 +++++++++++++++++-------------- > 1 file changed, 17 insertions(+), 14 deletions(-) > >diff --git a/C4/Patroncards/Patroncard.pm b/C4/Patroncards/Patroncard.pm >index f13d137..61ddcf1 100644 >--- a/C4/Patroncards/Patroncard.pm >+++ b/C4/Patroncards/Patroncard.pm >@@ -171,6 +171,7 @@ sub draw_text { > warn sprintf('No pdf object passed in.') and return -1 if !$pdf; > my @card_text = (); > return unless (ref($self->{'layout'}->{'text'}) eq 'ARRAY'); # just in case there is not text >+ > my $text = [@{$self->{'layout'}->{'text'}}]; # make a copy of the arrayref *not* simply a pointer > while (scalar @$text) { > my $line = shift @$text; >@@ -192,8 +193,8 @@ sub draw_text { > $line = join(' ',@orig_line); > } > my $text_attribs = shift @$text; >- my $origin_llx = $self->{'llx'} + $text_attribs->{'llx'}; >- my $origin_lly = $self->{'lly'} + $text_attribs->{'lly'}; >+ my $origin_llx = $self->{'llx'} + $text_attribs->{'llx'} * $self->{'unitvalue'}; >+ my $origin_lly = $self->{'lly'} + $text_attribs->{'lly'} * $self->{'unitvalue'}; > my $Tx = 0; # final text llx > my $Ty = $origin_lly; # final text lly > my $Tw = 0; # final text word spacing. See http://www.adobe.com/devnet/pdf/pdf_reference.html ISO 32000-1 >@@ -231,8 +232,8 @@ sub draw_text { > $string_width = C4::Creators::PDF->StrWidth($line, $text_attribs->{'font'}, $text_attribs->{'font_size'}); > #$font_units_width = $m->string_width($line); > #$string_width = ($font_units_width * $text_attribs->{'font_size'}) / $units_per_em; >- if (($string_width + $text_attribs->{'llx'}) < $self->{'width'}) { >- ($Tx, $Tw) = text_alignment($origin_llx, $self->{'width'}, $text_attribs->{'llx'}, $string_width, $line, $text_attribs->{'text_alignment'}); >+ if ( $string_width + ( $text_attribs->{'llx'} * $self->{'unitvalue'} ) < $self->{'width'}) { >+ ($Tx, $Tw) = text_alignment($origin_llx, $self->{'width'}, $text_attribs->{'llx'} * $self->{'unitvalue'}, $string_width, $line, $text_attribs->{'text_alignment'}); > $line =~ s/^\s+//g; # strip naughty leading spaces > push @lines, {line=> $line, Tx => $Tx, Ty => $Ty, Tw => $Tw}; > last WRAP_LINES; >@@ -241,7 +242,7 @@ sub draw_text { > } > } > else { >- ($Tx, $Tw) = text_alignment($origin_llx, $self->{'width'}, $text_attribs->{'llx'}, $string_width, $line, $text_attribs->{'text_alignment'}); >+ ($Tx, $Tw) = text_alignment($origin_llx, $self->{'width'}, $text_attribs->{'llx'} * $self->{'unitvalue'}, $string_width, $line, $text_attribs->{'text_alignment'}); > $line =~ s/^\s+//g; # strip naughty leading spaces > push @lines, {line=> $line, Tx => $Tx, Ty => $Ty, Tw => $Tw}; > } >@@ -258,7 +259,7 @@ sub draw_text { > else { > $box_height += $text_attribs->{'font_size'}; > } >- box ($origin_llx, $box_lly, $self->{'width'} - $text_attribs->{'llx'}, $box_height, $pdf); >+ box ($origin_llx, $box_lly, $self->{'width'} - ( $text_attribs->{'llx'} * $self->{'unitvalue'} ), $box_height, $pdf); > } > $pdf->Font($text_attribs->{'font'}); > $pdf->FontSize($text_attribs->{'font_size'}); >@@ -272,11 +273,12 @@ sub draw_image { > my ($self, $pdf) = @_; > warn sprintf('No pdf object passed in.') and return -1 if !$pdf; > my $images = $self->{'layout'}->{'images'}; >+ > PROCESS_IMAGES: > foreach my $image (keys %$images) { > next PROCESS_IMAGES if $images->{$image}->{'data_source'}->[0]->{'image_source'} eq 'none'; >- my $Tx = $self->{'llx'} + $images->{$image}->{'Tx'}; >- my $Ty = $self->{'lly'} + $images->{$image}->{'Ty'}; >+ my $Tx = $self->{'llx'} + $images->{$image}->{'Tx'} * $self->{'unitvalue'}; >+ my $Ty = $self->{'lly'} + $images->{$image}->{'Ty'} * $self->{'unitvalue'}; > warn sprintf('No image passed in.') and next if !$images->{$image}->{'data'}; > 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); > my $obj_stream = "q\n"; >@@ -291,6 +293,7 @@ sub draw_image { > sub _draw_barcode { # this is cut-and-paste from Label.pm because there is no common place for it atm... > my $self = shift; > my %params = @_; >+ > my $x_scale_factor = 1; > my $num_of_chars = length($params{'barcode_data'}); > my $tot_bar_length = 0; >@@ -310,8 +313,8 @@ sub _draw_barcode { # this is cut-and-paste from Label.pm because there is no > } > eval { > PDF::Reuse::Barcode::Code39( >- x => $params{'llx'}, >- y => $params{'lly'}, >+ x => $params{'llx'} * $self->{'unitvalue'}, >+ y => $params{'lly'} * $self->{'unitvalue'}, > value => "*$params{barcode_data}*", > xSize => $x_scale_factor, > ySize => $params{'y_scale_factor'}, >@@ -330,8 +333,8 @@ sub _draw_barcode { # this is cut-and-paste from Label.pm because there is no > $x_scale_factor = ($params{'width'} / $tot_bar_length) * 0.9; > eval { > PDF::Reuse::Barcode::COOP2of5( >- x => $params{'llx'}, >- y => $params{'lly'}, >+ x => $params{'llx'}* $self->{'unitvalue'}, >+ y => $params{'lly'}* $self->{'unitvalue'}, > value => "*$params{barcode_data}*", > xSize => $x_scale_factor, > ySize => $params{'y_scale_factor'}, >@@ -348,8 +351,8 @@ sub _draw_barcode { # this is cut-and-paste from Label.pm because there is no > $x_scale_factor = ($params{'width'} / $tot_bar_length) * 0.9; > eval { > PDF::Reuse::Barcode::Industrial2of5( >- x => $params{'llx'}, >- y => $params{'lly'}, >+ x => $params{'llx'}* $self->{'unitvalue'} , >+ y => $params{'lly'}* $self->{'unitvalue'}, > value => "*$params{barcode_data}*", > xSize => $x_scale_factor, > ySize => $params{'y_scale_factor'}, >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18550
:
63167
|
63219
|
63320
|
66932
|
67670
|
67671