Use Checksum and Supplement Data for Barcodes

Skip to end of metadata
Go to start of metadata
What is 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 little 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.

What is 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 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 in the figure below:

Figure: Difference between 2 and 5 digit supplemental barcodes

The above barcodes are generated using EAN13 symbology.
  • 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.
Aspose.BarCode & Checksum

Using Aspose.BarCode, developers can enable Checksum for the barcode by setting the EnableCheckSum property of the barcode class to true. Checksum can also be made visible or hidden in the barcode image by setting the EnableChecksum property to true or false.

[C#]
//Instantiate barcode object
BarCodeBuilder bb = new BarCodeBuilder();

//Set the Code text for the barcode
bb.CodeText = "1234567";

//Set the symbology type to Code39
bb.SymbologyType = Symbology.Code39Standard;

//Make the checksum to be visible on the barcode
bb.EnableChecksum = true;

//Save the image to your system
//and set its image format to Jpeg
bb.Save("barcode.jpg",
   System.Drawing.Imaging.ImageFormat.Jpeg);
 


[VB.NET]
'Instantiate barcode object
Dim bb As BarCodeBuilder = New BarCodeBuilder()

'Set the Code text for the barcode
bb.CodeText = "1234567"

'Set the symbology type to Code39
bb.SymbologyType = Symbology.Code39Standard

'Make the checksum to be visible on the barcode
bb.EnableChecksum = True

'Save the image to your system
'and set its image format to Jpeg
bb.Save("barcode.jpg",
   System.Drawing.Imaging.ImageFormat.Jpeg)
 

The output barcode image generated by the above code is shown below, where in Code text: "1234567", a character "S" appended at the end, is the Checksum.
Figure: Resulting barcode image generated after example code execution


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 Symbology always include checksum:

  • EAN13
  • EAN8
  • BooklandEAN
Aspose.BarCode & Supplement Data

It is possible to encode 2 or 5 Digit Supplement Data in the barcode using SupplementData property of any barcode generating class in Aspose.BarCode. Moreover, the space between the main barcode and supplemental barcode can also be customized by using the SupplementSpace property of all barcode generating classes.

[C#]
//Instantiate barcode object
BarCodeBuilder bb = new BarCodeBuilder();

//Set the Code text for the barcode
bb.CodeText = "123456789123";

//Set the symbology type to EAN13
bb.SymbologyType = Symbology.EAN13;

//Set the supplement data (5 Digit)
bb.SupplementData = "12345";

//Set space between the supplemental barcode and main barcode
bb.SupplementSpace = 2.0f;

//Save the image to your system
//and set its image format to Jpeg
bb.Save("barcode.jpg",
   System.Drawing.Imaging.ImageFormat.Jpeg);
 


[VB.NET]
'Instantiate barcode object
Dim bb As BarCodeBuilder = New BarCodeBuilder()

'Set the Code text for the barcode
bb.CodeText = "123456789123"

'Set the symbology type to EAN13
bb.SymbologyType = Symbology.EAN13

'Set the supplement data (5 Digit)
bb.SupplementData = "12345"

'Set space between the supplemental barcode and main barcode
bb.SupplementSpace = 2.0F

'Save the image to your system
'and set its image format to Jpeg
bb.Save("barcode.jpg",
   System.Drawing.Imaging.ImageFormat.Jpeg)
 

The output barcode generated by the above code is shown in the figure below:
Figure: Resulting barcode image generated after example code execution


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

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

SupplementSpace is the space between main barcode and the supplementdata, this setting generally will not affect the scan result. The following sample shows diffenent SupplementSpace settings:
Figure: SupplementSpace = 2



Figure: SupplementSpace = 4



Figure: SupplementSpace = 6

Always Display Checksum character on Code128 and EAN128 Barcodes

Code128 and EAN128 barcode symbologies also support checksum characters. To display the checksum character on the barcode image in human readable form, BarCodeBuilder.AlwaysShowChecksum property needs to be set.
The below code example generates a Code128 barcode. The checksum character is also displayed on the barcode image.

[C#]
// Generate EAN128 barcode
BarCodeBuilder builder = new BarCodeBuilder("0123456789", Symbology.Code39Standard);
// Always show checksum on image
builder.AlwaysShowChecksum = true;
builder.Save("test.png");
 
[VB.NET]
' Generate EAN128 barcode
Dim builder As BarCodeBuilder = New BarCodeBuilder("0123456789", Symbology.Code39Standard)
' Always show checksum on image
builder.AlwaysShowChecksum = True
builder.Save("test.png")
 

Below is the image that is generated with this code:
Codetext: 0123456789
Checksum: I

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.