Having seen GS-1 trying to charge to make barcodes, and how simple it is, I thought I would look more in to the specifications to make sure any barcodes we use are spot on.
I am quite surprised with the GS-1 documentation (here) on the matter. It is 455 pages long, and not only covers the detailed format of the barcodes, but different types of code (QR, Datamatrix, ITF, Code128) and placement on the products and all sorts. It goes in to massive amounts of detail!
I had written some basic 1D and 2D barcode generation libraries some time ago (As I said, I did a postscript EAN/UPC codes decades ago, and was printing my first barcodes on dot matrix printers when in school, something like 35 years ago).
I decided to check these and add some extra layers, e.g. tools to make an exactly correct GS-1 EAN/UPC/GTIN barcode covering EAN-8, UPC-E, UPC-A, EAN-13 and GTIN-14 as well as 2 and 5 digit add-on codes.
The basic coding is pretty simple, as I have said. Like most 1D barcodes the coding is done with multiples of a "unit" size. Systems that use thin and thick bars only often have non integer sizes, e.g. 2.5:1 ratios (ITF, Code39), and allow from say 2:1 to 3:1. However codes that use multiple sizes like EAN and UPC will usually use exact multiples of the unit size. EAN/UPC use 1, 2, 3, or 4 width bars or spaces. Obviously when printing you may have to slightly adjust artwork to allow for printer bleed which makes the black bars appear wider than they are, but the ideal final output has the exact multiples of the unit width.
That aspect was simple. However, there are other aspects to get it right such as the required quiet zone (white area at start and end) and the height of the bars, and text/digits shown, and so on. In practice the height does not matter much for scanning, other than the range of angles you can scan (which has some relevance for things like laser scanning at checkouts).
So, let's start - this is the basic EAN-13 code :-
As you can see, the GS-1 specification goes in to a lot of detail. This is based on a 0.33mm unit size, and all of the horizontal measurements are exact number of units (as you might expect). So, for example, the 3.63mm leading quiet zone is 11 units, and the trailing quiet zone of 2.31mm is 7 units. Simple.
Sadly the heights are not whole units, but they are specified. So I can make a barcode of those exact dimensions in SVG nicely.
Similarly the UPC-A code is well defined :-
As you can see, subtly different. Two of the digits are outside. The use of digits and symbols on left and right is probably to emphasis the need for quiet zones, as I am sure UPC used to have all 12 digits under the bars much like EAN-13 codes do. (FYI the extra initial digit in EAN-13 is encoded in the orientation of the first 6 digit's bars so does not take more space than 12 digit UPC).
As you will see, the quiet zones are different, being 9 units each side, but the overall size is the same at 37.29mm by 25.93mm. The UPC-A does define how much the guard bars go down in to the digits though, which is handy.
So, once again, I can make a perfect UPC-A barcode
So, I was quite pleased with myself and decided to code the 2 and 5 digit add on codes. These are used for periodicals, magazines, newspapers so the publication does not need a separate main barcode for each issue. Again, the coding is simple, but the dimensions are fun...
Lets look at a 5 digit add on with an EAN-13 code :-
This creates slight concern for me in two areas. Firstly the 1.65mm final quiet zone is 5 units, smaller than a digit takes (7 units) yet the ">" looks like it has plenty of space between it and the 8. Now, GS-1 don't seem to define the font, and I am using an OCR-B font (which you may not see in my examples) with a ">" that is slightly wider than shown. But if you look at the image above the 1.65mm shown is the same as the 2.31mm to 3.96mm quiet zone. Clearly a misleading image. I decided I would go for 7 units not 5 as the drawing clearly does not reflect the dimensions shown.
The other issue is the height. The side bars at 21.90mm, and from the above you can see the guard bars are 24.50mm leaving only 2.6mm at the top. Normally there is 3.08mm for the digits, so this is tight, yet it seems to be shown with more of a gap between the bars and the digits than those at the bottom. My example does not make the bars a full 21.90mm but instead allows just enough space for the digits.
However, it gets worse, this is the UPC-A with 2 digit add on:-
In this case the side bars do not go all the way to the bottom of the guard bars. This make sense else they clash with the final digit on the right of the main bar code. However, and this is where GS-1 clearly have something of cock up, the side bars are also 21.90mm high!
Given the height of the main bars over the digits is 22.85mm this leaves 0.95mm for the digits at the top, which is clearly not sensible and very much not as shown.
So I have just made mine sensible, allowing space for digits. If it was not obvious that the specification was clearly flawed I would follow it, indeed for the EAN-13 I initially did smaller digits, but when I got to UPC-A I realised it was impossible to follow the specification.
So, 455 pages, and still mistakes on some of the most basic aspects. Shame.
P.S. I would stress that whilst these are two minor deviations from the standard (where it is clearly a broken standard), they are not deviations in the actual scanned barcode itself, so not anything that impacts reading the barcode correctly.
I have mentioned before, but one of my pet hates is crossed zeros. I have gone in to the history a bit ( here ), but I still encounter these...
Broadband services are a wonderful innovation of our time, using multiple frequency bands (hence the name) to carry signals over wires (us...
The ASR33, like most teletypes of the era, works at a fixed rate. It does 10 characters per second. It is 110 Baud, using 1 start, 8 data (i...
I am using KiCad for PCB design, and it is pretty impressive, but KiCad version 6 has just been released. There are lots of small changes, b...