Saturday, May 16, 2009

UPCA Assembly for dotNET

Format UPC-A Barcodes using .NET assembly



I created a .NET assembly which when used with the associated UPC-A true type font, allows a developer to format UPC-A barcodes from any .NET project with just a few lines of code. As demonstrated here.

The assembly, barcode font and example project are avaialbe for free, for private or  non-commercial use. Just email me and I'll send you the entire package. 

Or download the zipped files from this link

This demostration assumes you're using Visual Studio and C#. Enjoy!

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 encodation. These extra digits are primarily used on periodicals and books. Supplemental
encodations 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:












































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


  1. 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


  1. Add the using clause as below

using ako.UPC_A;


  1. You can now construct a UPCA object and call it’s 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)

richTextBox1.Text = new UPCA(number_system,textBox1.Text).upca;

or…


  1. Construct a UPCA object then set the NumberSystem and Data properties ( assuming the rich text box font is set to the UPCA font)

UPCA upc = new UPCA();


upc.NumberSystem = "4";


upc.Data = textBox1.Text;


richTextBox1.Text = upc.upca;



  1. Obtain the formatted barcode from the upca property of the UPCA object e.g.(if declared as in (ii.) above)

richTextBox1.Text = upc.upca;


Notes:

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 below

public partial class UPCA : System.Object

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.

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.

  • No comments:

    Post a Comment