From a1f9e8efb6fe8e3cf77ae095e4795eff39baf568 Mon Sep 17 00:00:00 2001 From: Maryse Simard Date: Mon, 11 May 2020 14:20:42 -0400 Subject: [PATCH] Bug 25459: Makes barcode position respect units in patron cards layout When using any unit besides postscript points, barcode positionning doesn't work correctly. There is an error in the calculation: the unit factor must be applied to the individual card part only and not to the full page position. This patch moves the unit part of the calculation to the right place. To test : 1. Create a working patron card setup, using postscript points: card template, layout and card batch. Use barcode and at least one other element (text or images) in the layout. => Some tips for testing: - activate guides for the layout - use a template and a batch containing more than one card; the displacement will be different for each card and depend on the barcode position relative to the bottom left of the entire page. 2. Change units from postscript points to any other unit. => At least for the layout, but changing it in the template will scale the page as well. 4. Export the card batch. 3. Note the guides are scaled to fit the new unit and the lower left corner of text and images are still correctly placed relative to the guides, but the barcode is not. => In some cases, the barcode even seem to not print at all since it's new coordinates are out of screen. 4. Apply patch. 5. Generate the batch again. 6. Note the barcode now appears exactly where it should. Signed-off-by: George Veranis Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall --- C4/Patroncards/Patroncard.pm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/C4/Patroncards/Patroncard.pm b/C4/Patroncards/Patroncard.pm index 12a5ce36a3..485d6bcc1d 100644 --- a/C4/Patroncards/Patroncard.pm +++ b/C4/Patroncards/Patroncard.pm @@ -93,8 +93,8 @@ sub draw_barcode { my $barcode_width_scale = $self->{'barcode_width_scale'}; _draw_barcode( $self, - llx => $self->{'llx'} + $self->{'layout'}->{'barcode'}->[0]->{'llx'}, - lly => $self->{'lly'} + $self->{'layout'}->{'barcode'}->[0]->{'lly'}, + llx => $self->{'llx'} + $self->{'layout'}->{'barcode'}->[0]->{'llx'} * $self->{'unitvalue'}, + lly => $self->{'lly'} + $self->{'layout'}->{'barcode'}->[0]->{'lly'} * $self->{'unitvalue'}, width => $self->{'width'} * $barcode_width_scale, y_scale_factor => $self->{'height'} * $barcode_height_scale, barcode_type => $self->{'layout'}->{'barcode'}->[0]->{'type'}, @@ -375,8 +375,8 @@ sub _draw_barcode { # this is cut-and-paste from Label.pm because there is no } eval { PDF::Reuse::Barcode::Code39( - x => $params{'llx'} * $self->{'unitvalue'}, - y => $params{'lly'} * $self->{'unitvalue'}, + x => $params{'llx'}, + y => $params{'lly'}, value => "*$params{barcode_data}*", xSize => $x_scale_factor, ySize => $params{'y_scale_factor'}, @@ -395,8 +395,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'}* $self->{'unitvalue'}, - y => $params{'lly'}* $self->{'unitvalue'}, + x => $params{'llx'}, + y => $params{'lly'}, value => $params{barcode_data}, xSize => $x_scale_factor, ySize => $params{'y_scale_factor'}, @@ -413,8 +413,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'}* $self->{'unitvalue'} , - y => $params{'lly'}* $self->{'unitvalue'}, + x => $params{'llx'}, + y => $params{'lly'}, value => $params{barcode_data}, xSize => $x_scale_factor, ySize => $params{'y_scale_factor'}, -- 2.39.5