UPC-E1

  • 3 minutes to read

UPC-E is a shorter version of UPC-A. It omits the number system digit, leading zeros in the manufacturer code, and trailing zeros in the product code. UPC-E is used on products with small packaging where a full UPC-A barcode does not fit.

The UPC-E1 is a type of UPC-E code with the number system set to 1. In the human-readable barcode string, the first digit is the number system (always 1 for this code type), and the last digit is the check digit of the original UPC-A code.

Barcode - UPC-E1

In the above example, the original UPC-A code is 14210000526. This code (without the number system) is transformed into 425261, the checksum digit (1) is calculated automatically. The number system, the code, and the checksum digit are encoded in a format scanners can read.

NOTE

You should assign a code to the barcode’s Text property without the number system, since this digit is generated automatically. If it is not possible to convert a 10-digit code to a six-digit code, the barcode displays the “Invalid text format” error, and the digits to the right of the 10-th digit in the code are ignored.

Refer to the following article for more information: UPC-E.

Add the Bar Code to a Report

  1. Drag the XRBarCode item from the DX.20.2: Report Controls tab and drop it onto the report.

  2. Set the XRBarCode control’s Symbology property to UPCE1 (an object of the UPCE1Generator type).

  3. Specify common barcode properties.

Runtime Example

The following code creates the UPC-E1 barcode and specifies its properties.

NOTE

The complete sample project is available in the following repository: https://github.com/DevExpress-Examples/how-to-add-a-bar-code-to-a-report-e167.

using System;
using System.Collections.Generic;
using System.Drawing.Printing;
using System.Windows.Forms;
using DevExpress.XtraPrinting.BarCode;
using DevExpress.XtraReports.UI;
// ...
public XRBarCode CreateUPCE1BarCode(string BarCodeText) {
    // Create a bar code control.
    XRBarCode barCode = new XRBarCode();

    // Set the bar code's type to UPC-E1.
    barCode.Symbology = new UPCE1Generator();

    // Adjust the bar code's main properties.
    barCode.Text = BarCodeText;
    barCode.Width = 400;
    barCode.Height = 100;

    return barCode;
}

To add the XRBarCode to a report band, handle the report’s BeforePrint event.

using System.Drawing.Printing;
// ...

private void XtraReport1_BeforePrint(object sender, PrintEventArgs e) {
    this.Detail.Controls.Add(CreateUPCE1BarCode("4210000526"));
}