From 2ef35565481e29200830d0ef8acb4599476b95c3 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 --- 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 9251147420..ea1d077727 100644 --- a/C4/Patroncards/Patroncard.pm +++ b/C4/Patroncards/Patroncard.pm @@ -97,8 +97,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'}, @@ -378,8 +378,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'}, @@ -398,8 +398,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'}, @@ -416,8 +416,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