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
---
 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 8fd25fd..b26949e 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 d1ab98a..cf04e47 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<printing_type>        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

_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-patches
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to