KA.Barcode Generator for .NET Suite
How to Create & Resize UPC-A in C#
Complete C#.NET source code to generate UPC-A images and change barcode size with .NET Control
  • Support UPC-A generation & integration in .NET development environments like Microsoft Visual Studio
  • Printing, creating linear UPC-A, UPC-A +2, UPC-A +5 bar code images C#.NET class library
  • Easy-to-use barcode generator provided, such as Word barcode, barcode .NET WinForms, ASP.NET barcode & barcode Java
  • Stream UPC-A linear barcodes in ASP.NET web sites; draw UPC-A in WinForms; integrate into Crystal Reports
  • Compatible with GS1 General Specifications with automatic UPC-A checksum calculation function
  • Three units of measure for UPC-A creation through C# programming, including Pixel, Cm, and Inch
  • Rich options to easily adjust UPC-A dimensions like bar width, bar height, barcode width, barcode height
  • Data Matrix Word, Data Matrix C#, .NET WinForms Interleaved 2 of 5, ASP.NET Codabar and other linear & 2D barcode control provided
  • Support customizing quiet zones / margins on all four sides for UPC-A images
  • Mature barcoding creator for drawing, creating high-quality UPC-A printout for all printers and scanners
UPC-A, is also named Universal Product Code version A, UPC-A+2, UPC-A Supplement 2 (Two-digit Add-On), UPC-A+5, UPC-A Supplement 5 (Five-digit Add-On), UPC Bar Code, UPC Symbol, GTIN-12, GS1-12.
Developped with .NET technologies, KeepAutomation barcode encoder component SDK is the best available barcode printing & drawing control for .NET developers to generate UPC-A in ASP.NET, Winforms, C#, etc. This page is a complete C# source code tutorial for UPC-A generation and size setting withall kinds of barcoding parameters. Here are two more tutorials with data and size examples.
Install KA.Barcode Generator for .NET Suite into C#.NET Project
  1. 1.
  2. 2.
    Add Reference: Add "KeepAutomation.Barcode.Window.dll" to your C#.NET project reference.
How to Generate, Resize EAN13 Images in C# Class
Copy the following C#.NET barcoding program with sample code onto your project to create a UPC-A barcode image
using KeepAutomation.Barcode.Bean;

BarCode upca= new BarCode();
upca.Symbology = KeepAutomation.Barcode.Symbology.UPCA;
upca.CodeToEncode = "12345678901";
upca.X =2;


UPCA Barcode Unit

KA.Barcode Generator for .NET Suite supports generating UPC-A barcode images in Pixel, Cm and Inch units of measure. The default value is pixel, which is most commonly used. If you want to shift into other units of measure, simply follow the demo code below.
upca.BarcodeUnit = BarcodeUnit.Cm;            

UPC-A X Dimension / Bar Width

The UPC-A X dimension is usually referred to as the module bar width, i.e. the width of the narrowest bar. Default value is 1 pixel, which is the minimum value as specified in the GS1 specification. You can adjust UPC-A X dimension as follows.
upca.X = 2;

UPC-A Y Dimension / Bar Height

The UPC-A Y dimension stands for the bar height for a UPC-A image. Default value for bar height is 50 pixels. If you want it taller, just copy the C# code below into your .NET project.
ean13.Y = 55;

UPC-A Supplement Height and Space

There may be a time when you want to encode some extra information into a UPC-A image, then you will need a supplement add-on symbol. You can adjust the add-on bar height, and the space between add-on and primary barcode image.

Default supplement Height is 0.8, which means 80% of the primary bar height. It is valid from 0 to 1. Default value for Supplement space is 15 pixels. Here is the C# demo code to adjust both parameters.
upca.Symbology = KeepAutomation.Barcode.Symbology.UPCASup2;
upca.SupplementCode = "12"
upca.SupplementHeight = 0.6;
upca.SupplementSpace = 18;

UPC-A Quiet Zone / Margin

According the GS1 General Specification for UPC-A, a minimum 10X quiet zone is required on both the left and the right sides of UPC-A image. Default value is 0. If you want more margins, just refer to the demo code below.
upca.LeftMargin = 5;
upca.RightMargin = 5;
upca.TopMargin = 5;
upca.BottomeMargin = 5;

UPC-A Barcode Width and Barcode Height

If you want to create a UPC-A image with a fixed barcode width and a specific barcode height, you can adjust both properties with the demo code below.

Please note that there may be an occasion when the generated image width is the larger than the value you assign, because the value you set is less than the minimum value, which is calculated by the UPC-A encoding pattern as specified in the GS1 standard. When that happens, you can choose to either reduce encoding data,or set smaller value to X / larger value to barcode width.
upca.BarCodeWidth = 200;
upca.BarCodeHeight = 70;