Click here to Skip to main content
12,952,112 members (56,158 online)
Click here to Skip to main content
Add your own
alternative version


9 bookmarked
Posted 17 May 2009

Format UPC-A Barcodes Using a .NET assembly

, 17 May 2009 CPOL
Rate this:
Please Sign up or sign in to vote.
The attached assembly, used with the associated font, allows a developer to format UPC-A barcodes from any .NET project in a just a few lines of code.


The attached assembly, used with the associated font, allows a developer to format UPC-A barcodes from any .NET project in just a few lines of code, as demonstrated here.

Highly skippable backgrounder

The Universal Product Code (UPC) specifications include three versions: A, D, and E. Version A, the regular version, is used to encode a twelve digit number. Version E, the zero suppressed version, is a six digit code used for marking small packages. Version D, the variable length version, is not commonly used for package marking. It is used in limited special applications.

Both Version A and E may include either a 2 digit or a 5 digit supplemental encoding. These extra digits are primarily used on periodicals and books. Supplemental encodings are supported.

Version A encodes a twelve digit number. The first number encoded is the number system character, the next ten digits are the data characters, and the last digit is the check character.

The number system character is printed in human readable form to the left of the UPC symbol. Seven of the ten possible numbers have been assigned.

UPC Number System Characters

0Regular UPC codes
2Random weight items which are symbol marked at the store level
3National Drug Code and National Health related Items Code
4For use without code format restrictions and with check digit protection for in-store marking of non-food items.
5For use on coupons
6Regular UPC codes
7Regular UPC codes

These number system characters are accessible as the UPCA.NumberSystem property of the UPCA object in the assembly.

Assembly Usage

In order to use the assembly and format UPC-A barcodes, download the attached zip files, unzip them, and follow the steps outlined below:

  1. First ensure that the UPCA font is installed on the target system
    1. Navigate to Control Panel and click on it to open.
    2. Double click fonts in Control Panel to open the Fonts Control Panel applet.
    3. Either drag the UPCA font into the fonts cache (the Fonts Control Panel applet) or click File->Install new font… navigate to the UPCA font, and select it.
  2. Add the UPCA assembly to your project in the following manner:
    1. Copy the assembly to your project folder.
    2. Add a reference to the assembly in your project.
    3. Add the using clause as below:
    4. using ako.UPC_A;
  3. You can now construct a UPCA object and call its methods in the following manner (also see the attached example project).
    1. Construct a UPCA object with a number system and barcode data (assuming the rich text box font is set to the UPCA font).
    2. richTextBox1.Text = new UPCA(number_system, textBox1.Text).upca;


    3. Construct a UPCA object, then set the NumberSystem and Data properties (assuming the rich text box font is set to the UPCA font).
    4. UPCA upc = new UPCA();
      upc.NumberSystem = "4";
      upc.Data = textBox1.Text;
      richTextBox1.Text = upc.upca;
    5. Obtain the formatted barcode from the UPCA property of the UPCA object e.g. (if declared as in (ii.) above):
    6. richTextBox1.Text = upc.upca;


  1. The UPCA object is declared as a partial class, allowing a user to extend its functionality as required (reference .NET partial classes). The actual declaration is shown below:
  2. public partial class UPCA : System.Object
  3. The read only UPCA.upca property is formatted to include all the data required for a properly formatted UPC-A barcode, including leading and trailing barcode stop characters, distinct left and right barcode characters, and the middle barcode characters.
  4. The UPCA font is free for personal, non-commercial use, but requires licensing for commercial use. If you require the font for commercial purposes, please contact me ( for details.


First version and first article; any and all comments appreciated.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Agola K. Odero
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions upc-a sdk Pin
Zacbr1-Feb-12 3:40
memberZacbr1-Feb-12 3:40 
Questionbarcode in code 39 Pin
Member 79252208-Jul-11 22:30
memberMember 79252208-Jul-11 22:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170525.1 | Last Updated 17 May 2009
Article Copyright 2009 by Agola K. Odero
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid