KA.Barcode Generator for .NET Suite
How to Generate UPC-A Image in C# Projects
Complete C# source code to generate UPC-A images in different image formats using Barcode for .NET
  • Draw, print UPC-A, UPC-A+2, UPC-A+5 linear barcodes in .NET Framework 2.0, 3.0, 3.5 and above versions
  • Dynamically create and make 1D UPC-A bar codes in ASP.NET web forms, Windows applications, Crystal Reports
  • Other barcode solutions provided - barcode .NET, Excel barcode, Word barcode, etc.
  • Programmatically barcoding and generating UPC-A in Visual C# class & console applications
  • Generate UPC-A barcodes in Png, Jpeg/Jpg, Gif, Tiff, Bmp image formats and save locally using C#.NET
  • Compatible with latest GS1 General Specifications for UPC-A for valid image generation
  • .NET WinForms ITF-14, Intelligent Mail .NET, .NET WinForms ISBN, VB.NET Interleaved 2 of 5 & EAN-8 ASP.NET can be created as well
  • Checksum digit and quiet zones automatically added as specified in GS1 standard
  • Simple to change barcode position by rotating UPC-A image in 0, 90, 180, 270 degrees in Visual C#.NET
  • Customize supplemental bar height, space, human readable text easily in C# programming
UPC-A is a GS1 barcode symbology also named as 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.
KA.Barcode Generator for .NET Suite is a high-quality C# barcoding maker control package, which allows you to implement high-quality 1D UPC-A barcode images and other symbologies in .NET applications using Visual C#.NET. This page provides C# demo code on UPC-A image setting. For more code on data encoding and size setting functionality, navigate to the following tutorial pages.
How to Generate, Specify UPC-A Barcode Images in C# Class

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.
  3. 3.
    Copy the following example C#.NET Code onto your project to create, make a linear 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.generateBarcodeToImageFile("C:/upca.png");

UPC-A Barcode Margins / Quiet Zones

According to the GS1 General Specification Version 8 for UPCA, a minimum 10X margin (10 times the width of the module bar) is required both on the left and right sides of the barcode images, which is generally referred to as Quiet Zone in barcode specifications.
The left and right quiet zones are automatically added by KA.Barcode Generator for .NET Suite to ensure UPC-A image readability. Default value for margin is 0. If you want extra margin, please copy the demo code below into your C#.NET project.
upca.LeftMargin = 2;
upca.RightMargin = 2;
upca.TopMargin = 2;
upca.BottomMargin = 2;

UPC-A Image Formats

KeepAutomation barcode generator for C#.NET supports printing UPC-A barcodes in different image formats, including Png, Jpeg/Jpg, Gif, Tiff, Bmp, etc. Copy the C# sample code below and save UPC-A barcodes to specific image file.
upca.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;
upca.generateBarcodeToImageFile("C:/upca.png");

UPC-A Supplemental Bar Height

If you want to generate an UPC-A barcode with a two-digit or a five-digit add-on symbol, i.e. the EAN-13+2 (EAN13Sup2), EAN-13+5 (EAN13Sup5), you might want to adjust the supplemental bar height and supplemental bar space. The supplemental bar height is a float value, with a default value 0.8F, which means the supplemental bar height is 80% the height of the primary bar height.
upca.Symbology = Symbology.UPCASup2; 
upca.CodeToEncode = "12345678901";
upca.SupplementCode = "22";
upca.SupplementHeight = 0.7F;

UPC-A Supplemental Bar Space

UPC-A supplemental bar space refers to the space between the add-on symbol and the primary bar code symbol. Default value is 15 pixels. You can adjust this parameter with the C#.NET sample code below.
upca.SupplementSpace = 0.2F;