Use Checksum and Supplement Data for Barcodes

What is a checksum?

A checksum is an error detection scheme in which some additional characters are added to a barcode to protect the integrity of barcode data. Checksums are not necessary for all kinds of barcodes. For example, Code128 and Code39 are self-checking and checksums for such symbologies are not necessary. But on the other hand, another symbology like Interleaved2Of5, which can only represent numeric data, has very few spaces between its bars and is prone to substitution errors. So, for such symbologies, checksums are necessary. There are also some symbologies such as UPC (Universal Product Code) that require a checksum.

Coding Checksums

Using Aspose.BarCode, developers can enable checksum for a barcode by passing “true” to the getParameters().getBarcode().setChecksumEnabled() method of the barcode class. The checksum can also be made visible or hidden in the barcode image by passing true or false to setChecksumEnabled() method.

The EnableChecksum enumeration is defined as follows:

Enum Constant Description
DEFAULT If the checksum is required by the specification - it will be attached.
NO Do not use a checksum.
YES Always use checksum if possible.

The output barcode image generated by the above code is shown below. In the code text, “1234567”, the checksum is the character “S” appended at the end.

todo:image_alt_text
Figure: Output barcode showing checksum

Always Show Checksums

The checksum can always be shown using the following code snippet.

Checksum Applicable Symbologies

Once the EnableChecksum property is set to true, the checksum is shown on the barcode image. Applicable symbology:

  • Code11
  • Code39Extended
  • Code39Standard
  • Code93Extended
  • Code93Standard
  • Interleaved2of5
  • Standard2of5

The following symbologies always include a checksum:

  • EAN13
  • EAN8
  • BooklandEAN

What is a supplemental barcode?

UPCA, UPCE, EAN13 and EAN8 symbologies may all include an additional barcode to the right of the main barcode. This second barcode that is usually not as tall as the main barcode, is called a supplemental barcode and is used to encode additional information for newspapers, books, and other periodicals.

The supplemental barcode may either encode 2 or 5 digits of information as shown below.

todo:image_alt_text
Figure: Difference between 2 and 5 digit supplemental barcodes
The above barcodes are generated using EAN13 symbology.

Supplemental Barcodes

2-digit supplemental barcodes are mostly used with magazines, newspapers and other such periodicals. The 2-digit supplement represents the issue number of the magazine that can be used to track which issue of the magazine is being sold, perhaps for sales analysis or restocking purposes.

5-digit supplemental barcodes are used on books to indicate a suggested retail price. The first digit of the supplement indicates the currency in which the price is expressed. A “0” represents a price expressed in British Pounds whereas a “5” represents a price expressed in US Dollars. The remaining 4 digits of the supplement indicate the price.

Coding with Supplement Data

It is possible to encode -2 or 5-digit supplement data in the barcode using getSupplement().setData() method of the BarCodeGenerator class in Aspose.BarCode. Moreover, the space between the main barcode and supplemental barcode can also be customized by using the getSupplement().getSpace() method as shown below.

The output barcode generated by the above code is shown in the figure below:

todo:image_alt_text
Figure: Resulting barcode image generated after example code execution

Symbologies that support Supplemental Barcodes

The barcode symbologies, which support supplemental barcodes are as follows:

  • UPCA
  • UPCE
  • EAN13
  • EAN8
  • BooklandEAN
  • Interleaved2of5
  • Standard2of5

SupplementSpace is the space between the main barcode and the supplement data, this setting generally will not affect the scan result. The following sample shows different SupplementSpace settings:

todo:image_alt_text
Figure: SupplementSpace = 2
todo:image_alt_text
Figure: SupplementSpace = 4
todo:image_alt_text
Figure: SupplementSpace = 6