Skip to main content
A newer version of this page is available. .

UPC-A

  • 3 minutes to read

Short Description

The UPC-A bar code is by far the most common and well-known symbology, especially in the United States. A UPC-A bar code is the bar code you will find on virtually every consumer item on the shelves of your local supermarket, as well as books, magazines, and newspapers. It is called simply, a “UPC bar code” or “UPC Symbol.”

Barcode - UPC-A

The UPC-A bar code contains 12 digits, no letters or other characters. The first digit is the prefix signifying the product type. The last digit is the “check digit”. The check digit is calculated using first eleven figures when the bar code is constructed. So, for the correct UPC-A you should specify only the first 11 digits.

The recommended dimensions are shown in the picture. The standard allows magnification up to 200%, and reduction of up to 80% of the recommended size.

There should be two quiet zones before and after the bar code. They provide reliable operation of the bar code scanner. The quiet zone recommended length is 2.97 mm for the bar code of standard width and height.

Bar Code Properties

The type of a bar code control’s Symbology property is UPCAGenerator.

The are no properties specific to the UPC-A bar code type.

Note

The control does not verify the length of the assigned character string specified by the bar code control’s Text value. It is the developer’s responsibility to check that the passed string contains no more than 11 digits (the control calculates the last twelfth digit automatically). If the number of digits is less than 11, the leading zeroes are added to the resulting bar code.

Examples

The following code creates a UPC-A bar code and specifies its main properties.

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

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

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

    return barCode;
}

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

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

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