Click here to Skip to main content
Click here to Skip to main content

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.

Introduction

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

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

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;

      or…

    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;

Notes

  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 (agolakisira@gmail.com) for details.

History

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

License

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

Share

About the Author

Agola K. Odero

United States United States
No Biography provided

Comments and Discussions

 
Question.net upc-a sdk PinmemberZacbr1-Feb-12 3:40 
Questionbarcode in code 39 PinmemberMember 79252208-Jul-11 22:30 

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

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

| Advertise | Privacy | Mobile
Web03 | 2.8.141015.1 | Last Updated 17 May 2009
Article Copyright 2009 by Agola K. Odero
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid