From 8d79006ec24cd2d4e1bf418cf4b2d3fc8fb6d872 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sat, 4 Jun 2011 14:23:20 +0200 Subject: [PATCH] Bug 6448 [3/3] EAN-13 barcode labels Current implementation doesn't scale barcodes because low-price CCD barcode readers are very sensitive about size Test scenario: 1. in Tools > Labels create or edit Layout and select EAN13 as barcode type 2. export one of existing batches using EAN13 layout and verify that generated pdf file contains barcodes 3. print pdf file and test it with barcode reader Signed-off-by: Chris Cormack --- C4/Creators/Lib.pm | 2 +- C4/Labels/Label.pm | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletions(-) diff --git a/C4/Creators/Lib.pm b/C4/Creators/Lib.pm index 67ee0e8..0a57b59 100644 --- a/C4/Creators/Lib.pm +++ b/C4/Creators/Lib.pm @@ -90,7 +90,7 @@ my $barcode_types = [ {type => 'CODE39MOD', name => 'Code 39 + Modulo43', desc => 'Translates the characters 0-9, A-Z, \'-\', \'*\', \'+\', \'$\', \'%\', \'/\', \'.\' and \' \' to a barcode pattern. Encodes Mod 43 checksum.', selected => 0}, {type => 'CODE39MOD10', name => 'Code 39 + Modulo10', desc => 'Translates the characters 0-9, A-Z, \'-\', \'*\', \'+\', \'$\', \'%\', \'/\', \'.\' and \' \' to a barcode pattern. Encodes Mod 10 checksum.', selected => 0}, {type => 'COOP2OF5', name => 'COOP2of5', desc => 'Creates COOP2of5 barcodes from a string consisting of the numeric characters 0-9', selected => 0}, -# {type => 'EAN13', name => 'EAN13', desc => 'Creates EAN13 barcodes from a string of 12 or 13 digits. The check number (the 13:th digit) is calculated if not supplied.', selected => 0}, + {type => 'EAN13', name => 'EAN13', desc => 'Creates EAN13 barcodes from a string of 12 or 13 digits. The check number (the 13:th digit) is calculated if not supplied.', selected => 0}, # {type => 'EAN8', name => 'EAN8', desc => 'Translates a string of 7 or 8 digits to EAN8 barcodes. The check number (the 8:th digit) is calculated if not supplied.', selected => 0}, # {type => 'IATA2of5', name => 'IATA2of5', desc => 'Creates IATA2of5 barcodes from a string consisting of the numeric characters 0-9', selected => 0}, {type => 'INDUSTRIAL2OF5', name => 'Industrial2of5', desc => 'Creates Industrial2of5 barcodes from a string consisting of the numeric characters 0-9', selected => 0}, diff --git a/C4/Labels/Label.pm b/C4/Labels/Label.pm index 7b1fafd..87f44d1 100644 --- a/C4/Labels/Label.pm +++ b/C4/Labels/Label.pm @@ -553,6 +553,28 @@ sub barcode { warn sprintf('Barcode generation failed for item %s with this error: %s', $self->{'item_number'}, $@); } } + elsif ($params{'barcode_type'} eq 'EAN13') { + $bar_length = 4; # FIXME + $num_of_bars = 13; + $tot_bar_length = ($bar_length * $num_of_bars) + ($guard_length * 2); + $x_scale_factor = ($params{'width'} / $tot_bar_length) * 0.9; + eval { + PDF::Reuse::Barcode::EAN13( + x => $params{'llx'}, + y => $params{'lly'}, + value => sprintf('%013d',$params{barcode_data}), +# xSize => $x_scale_factor, +# ySize => $params{'y_scale_factor'}, + mode => 'graphic', + ); + }; + if ($@) { + warn sprintf('Barcode generation failed for item %s with this error: %s', $self->{'item_number'}, $@); + } + } + else { + warn "unknown barcode_type: $params{barcode_type}"; + } } sub csv_data { @@ -608,6 +630,9 @@ This module provides methods for creating, and otherwise manipulating single lab =item . INDUSTRIAL2OF5 = The standard 2 of 5 barcode (a binary level bar code developed by Identicon Corp. and Computer Identics Corp. in 1970) +=item . + EAN13 = The standard EAN-13 barcode + =back C Defines the general layout to be used on labels. NOTE: At present there are only five printing types supported in the label creator code: -- 1.7.2.5