Barcode Use with Mandalay CS

This article describes general guidelines for using barcodes with MandalayCS. These may be used for voucher barcodes or as other Electronic Identification (EID) within Mandalay software.

Background

Although many barcodes appear the same to human eyes, there are in fact a large number of different types. Each has its own advantages. Code128 is a very popular barcode type (it is used on most packaging for example). It has the following advantages:

  • Can encode the full set of characters, including lower-case.
  • Can encode purely numeric data in a very high density.
  • Includes a checksum digit to prevent misreads.
  • Pretty much off-the-shelf barcode scanners ship with Code128 enabled.

Its disadvantages include:

  • Cannot simply print the value using a special font  the input data has to be manipulated first.
  • Checksum calculation adds an extra character which is not straight-forward to determine.
  • Three variants, which can increase confusion.

Barcode Printing

As barcodes are intended to be read by a machine, care must be taken to ensure barcodes are present such that the machine can read them. The following points should be considered when printing barcodes:

  • To determine minimum recommended barcode width, take the number of characters being encoded (halved if using Code128-C), add three (for the start, end and checksum characters) and multiply by 0.33cm. So a 12 character barcode should be around 5cm long (or just over 3cm if using Code128-C).
  • Absolute minimum height with a typical hand-held scanner is 1cm. However we recommend going to 2cm to 2.5cm height to make alignment of the barcode and the scan-line easier. It may be necessary to repeat the font on subsequent lines to achieve the desired height.
  • An alternative way of thinking of this is that the height of a barcode should be approximately one third of its width.
  • A barcode needs to have a blank (“quiet”) area before and after it to ensure a reliable read. This should be a minimum of 0.8cm wide.
  • Surrounding a barcode with a box is not recommended. This can confuse some barcode scanners, particularly if the quiet area is narrow.
  • It is a good idea to include a human-readable version of the data encoded in the barcode below it. This can then be used by operators for manual entry if there are issues with the printed barcode or the scanner.
  • If printing using a thermal printer (or other printer type with a linear head), reliability can be improved by aligning the barcode vertically rather than horizontally. The reason for this is that any failed element in the print head can create blank vertical lines, which interfere with the barcode. If printer vertically (sometimes referred to as ladder orientation) then these blank lines will run along the barcode and no detail is lost, allowing it to still be read.

Code128 Variants

Code128 has three sub-variants; Code128-A, Code128-B and Code128-C. A single barcode can switch between these. The features of each are as follows:

  • Code128-A - Can encode numbers, upper case letters and control codes.
  • Code128-B - Can encode numbers, upper and lower case characters. Recommended if text needs to be encoded within the barcode.
  • Code128-C - Can encode only digits, but uses half the space as the other two versions. Recommended if only numeric data is to be encoded.

If only numbers need to be encoded (which is typically the case for vouchers), then Code128-C is the best choice. As it uses half the space for the same code as the other two versions, it is easier to align for scanning, and may be printed at a larger point size (which can help allow a barcode to scan under adverse conditions).

Code128 Barcode Generation

Generation of Code128 barcodes is a little more complex than just printing out the numbers in a special font. Due to the nature of Code128, the characters need to be manipulated, start and stop characters added, and a checksum calculated. Included with this document is a spreadsheet and a freely-available Code128 font to generate valid Code128 barcodes.

Within the spreadsheet are two tabs; one for the Code128-B variant and one for Code128-C. Each works in a similar way. Adjust the “Input Digits” row to change the input data. Avoid changing anything outside the existing input digits however. A third tab provides mapping between normal characters and the Code128 codes that are used to represent them. Note that it will be necessary to install the two fonts included before the spreadsheet can be used.

If barcodes are to be printed by a third-part (e.g. print bureau, typesetters, etc) it is important that they understand these rules and your specific requirements. If possible, a sample should be generated and validated using a scanner before a full print run is performed.

Resources

Free barcode font:   http://freebarcodefonts.dobsonsw.com/

Wikipedia Code128 Barcodes: http://en.wikipedia.org/wiki/Code_128