Barcodes

In the Spring of 1987, a large manufacturing company sent a notice to all of its suppliers. This notice informed them that their large customer was taking steps to modernize its supply chain. All of the suppliers to this Fortune 50 company would be required to place labels on all packages shipped. These labels looked very similar to the one pictured below in Figure 1.

AIAG Shipping Label

Figure 1. AIAG shipping label

At that time, I worked for one such supplier. We had to comply, but we had a choice.

  1. We could pay a considerable fee for the hardware and software to print these labels.
  2. We could develop the software in-house and use equipment we already owned.

My boss asked me to pursue the less expensive option.

I was a devotee of the “Guru” Don Lancaster. (Don is an author and a thought leader in electronics and desktop publishing.) His monthly column “Ask the Guru” in Computer Shopper magazine, was replete with tips, tricks and techniques for modifying electronics, programming the Apple ][ and utilizing the PostScript programming language to get an Apple LaserWriter to do things that desktop publishing experts find difficult to this day. Naturally, I was keen to try my hand at developing software for printing barcodes with PostScript.

The company we supplied our products to was a member of the Automotive Industry Action Group (AIAG). Consequently, our shipping labels needed to follow AIAG specifications. In just two weeks after studying the AIAG shipping label specification, I was generating label sheets full of barcodes using an Apple //c and an Apple LaserWriter Plus.

The key to creating these barcodes in such short order hinged on my insight into both the form and functionality of a barcode. You see barcodes are not just a series of thick and thin lines stacked sideways on a page, but a challenge computers were wonderfully suited to achieve.

I can’t seem to remember when I first learned of Morse code. I can assure you it was early in my life. Radio, television and movies feature people sitting around a desk tapping on a device generating sound effects that convey urgency and importance. Morse code over radio and wire consists of multiple series of dots, dashes and space in between. This signal is translated by a trained human ear into a language we all understand.

A barcode symbol is a computer’s Morse code. While we see a sideways stack of thin and thick lines and spaces, computers see only the thinnest cross-section of those lines using lasers and mirrors (see Figure 2). The signal is transformed into the computer’s native 1’s and 0’s. The image becomes a series of dots and dashes and then translation to numbers and letters occurs in software.

Figure 2. The thin red line

 

Generating a barcode from a printer is not necessarily a different story. Anyone who has worked with computer graphics knows the unfortunate side effect of unintentionally scaling one dimension of a picture without keeping the entire picture’s aspect ratio constant. The aspect ratio is a ratio of width to height. When a 200 x 150 image becomes a 200 x 1500 image an interesting effect is evident (See Figure 3). If the original image is a recognizable object, it becomes unrecognizable. However, if the image starts as a monochrome series of dots and dashes 11 pixels wide by one pixel high, you get a barcode.

Dahlia

Figure 3. Picture on left is original

 

becomes…

 

 

 

 

 

 

 

When the same relative scaling is applied to dots and dashes, however, 10451657780766985Stop becomes…

10451657780766985Stop

This effect is achieved with HTML image tags buried in this article. Use the browser’s ‘View Source’ option to see the code. It isn’t pretty, but you will see in time that it is elegant.

This is the technique I am using to create a barcode within the browser. In the next article, I’ll walk through the code and some of the necessary mechanics to use the client-side Code 128 barcodes in your own browser. Until next time, thank you for tuning in.