Home > .NET Barcode > C# Barcode Generation Guide > C# EAN13 Generator Component for .NET


EAN-13 Generator Library for .NET in C# Class

How to Generate Linear EAN13 Barcodes in .NET with C# Programming


  • Highly performance C# EAN-13 Barcode Generator SDK in use for more than 10 years
  • Generate high-quality EAN-13 images with simple C# Class programming
  • Create and Draw EAN-13 barcode in C# .NET WinForms or Web applications
  • Create and encode EAN-13 barcodes to various image formats
  • Easy to install without any activation key or registration code
  • Perfect integration with various .NET development environments, like Microsoft Visual Studio

C# Linear EAN13 Barcode Overview

Linear EAN13 Barcode is widely used in daily products. This barcode type can only encode 12 numeric data and a check digit, but it could store much information like manufacturer code, product information and area code. So with those codes, EAN13 barcode could track product worldwide and this is also why it is used to encode GITN.




Quick to Create, Print EAN-13 Barcode using C#

Using BarcodeLib C# Barcode Generator library, you can easily create and print an EAN-13 barcode image using C#.
  • Create a Linear object to generate 1d barcodes
  • In property Type, specify the linear barcode format as BarcodeType.EAN13
  • Enter the EAN-13 code (12 or 13 digits) to property Data
  • Use the method drawBarcode() to encode and output the EAN-13 barcode to an image file
Linear barcode = new Linear();
barcode.Type = BarcodeType.EAN13;
barcode.Data = "1234567890128";
barcode.drawBarcode("C://BarcodeLib//csharp-ean13-sample-image.png");





Encode EAN-13 digits in C# application



EAN-13 with Add-on symbol

EAN-13 barcode may include 2-digit or 5-digit add-on symbol. To create EAN-13 with two-digit add-on, try the C# codes below.
  • Select the barcode Type as BarcodeType.EAN13_2
  • Enter the two digits add-on data on property SData
Linear barcode = new Linear();
barcode.Type = BarcodeType.EAN13_2;
barcode.Data = "123456789012";
barcode.SData = "12";
barcode.drawBarcode("C://BarcodeLib//csharp-ean13-addon-2-sample-image.png");





Same as EAN-13 with two-digit addon, to generate EAN-13 with five-digit add-on, try the C# codes below.
  • Select the barcode Type as BarcodeType.EAN13_5
  • Enter the five digits add-on data on property SData
Linear barcode = new Linear();
barcode.Type = BarcodeType.EAN13_5;
barcode.Data = "123456789012";
barcode.SData = "12345";
barcode.drawBarcode("C://BarcodeLib//csharp-ean13-addon-5-sample-image.png");



EAN-13 check digit

EAN-13 barcode code includes 13 digits. The first 12 digits are EAN data, and the last digit is the check digit. Using BarcodeLib C# Barcode library, you can input the complete 13 digits or the frist 12 digits to property Data, and the barcode library will automatically generate the complete EAN-13 barcode images in C# application.

The following C# source code will provide the 12 digits data for property Data.
Linear barcode = new Linear();
barcode.Type = BarcodeType.EAN13;
barcode.Data = "123456789012";
barcode.drawBarcode("C://BarcodeLib//csharp-ean13-no-check-digit.png");





The following C# source code will provide the EAN-13 13 digits data with wrong check digit (the last digit) for property Data. The barcode library will always re-calculate the EAN-13 check digit based on the first 12 digits code.
Linear barcode = new Linear();
barcode.Type = BarcodeType.EAN13;
barcode.Data = "1234567890120";
barcode.drawBarcode("C://BarcodeLib//csharp-ean13-incorrect-check-digit.png");





Print EAN-13 with specified dimension size in C#

  • Set property ImageWidth with the specified EAN-13 image width in pixel
  • Set property ImageHeight with the specified EAN-13 image height in pixel
Linear barcode = new Linear();
barcode.Type = BarcodeType.EAN13;
barcode.Data = "1234567890128";
barcode.ImageWidth = 250;
barcode.ImageHeight = 180;
barcode.drawBarcode("C://BarcodeLib//csharp-ean13-barcode-size.png");





Advanced EAN-13 Customization using C#



Show, hide EAN-13 quiet zone indicator

You can enable and render EAN quiet zone indicator (sign ">") in the end of EAN-13 barcode text in C# application.
  • Enable property EANUPCShowIndicator to true to print EAN quiet zone indicator
Linear barcode = new Linear();
barcode.Type = BarcodeType.EAN13;
barcode.Data = "1234567890128";
barcode.EANUPCShowIndicator = true;
barcode.drawBarcode("C://BarcodeLib//csharp-ean13-quiet-zone-indicator.png");



EAN-13 first, last digit spacing

You can adjust the space between the first, the last (quiet zone indicator) character and the bar modules) using C# Barcode library.
  • Set the space tween the first char and EAN-13 barcode to property EANUPCFirstDigitShift
  • Set the space tween EAN-13 barcode and the last char (quiet zone indicator) to property EANUPCLastDigitShift
Linear barcode = new Linear();
barcode.Type = BarcodeType.EAN13;
barcode.Data = "1234567890128";
barcode.EANUPCShowIndicator = true;
barcode.EANUPCFirstDigitShift = 20;
barcode.EANUPCLastDigitShift = 20;
barcode.drawBarcode("C://BarcodeLib//csharp-ean13-lead-trail-digit-shift.png");





Styling EAN-13 Barcodes using C#



Customize EAN-13 Text style using OCR-B font

The GS1 standard recommends to use OCR-B font to render EAN-13 barcode text. If your system has installed the OCR-B font, you can try the following C# code to apply the font style.
  • Set the property TextFont with the new font name. Note: the C# code below will not modify the EAN-13 font size.
Linear barcode = new Linear();
barcode.Type = BarcodeType.EAN13;
barcode.Data = "1234567890128";
barcode.TextFont = new Font("OCR-B", 16);
barcode.drawBarcode("C://BarcodeLib//csharp-ean13-text-font-family.png");



Customize EAN-13 bar, space, text colors

You can print and customize the EAN-13 bar, space module colors and text labe colors through property BarColor, BackgroundColor and TextFontColor using C# Barcode library.
Linear barcode = new Linear();
barcode.Type = BarcodeType.EAN13;
barcode.Data = "1234567890128";
barcode.BarColor = Color.Red;
barcode.BackgroundColor = Color.LightSeaGreen;
barcode.TextFontColor = Color.Red;
barcode.drawBarcode("C://BarcodeLib//csharp-ean13-barcode-colors.png");





Quick to Create, Print Code 128 Barcode using C#



Create high resolution EAN-13 barcode images

If you need create high quality EAN-13 barcode images for printing, you'd better create EAN-13 image with high resolution setting through property Resolution in C# code.
Linear barcode = new Linear();
barcode.Type = BarcodeType.EAN13;
barcode.Data = "1234567890128";
barcode.UOM = UnitOfMeasure.INCH;
barcode.ImageWidth = 2;
barcode.ImageHeight = 1;
barcode.Resolution = 900;
barcode.drawBarcode("C://BarcodeLib//csharp-ean13-image-resolution.png");



Print EAN-13 to SVG, EPS vector image formats

You can also create and print EAN-13 barcode to vector images (SVG or ESP) for printing purpose.
  • Set the property ImageFormat with target output image format. BLImageFormat.SVG for SVG, BLImageFormat.EPS for EPS
Linear barcode = new Linear();
barcode.Type = BarcodeType.EAN13;
barcode.Data = "1234567890128";
barcode.ImageFormat = BLImageFormat.SVG;
barcode.drawBarcode("C://BarcodeLib//csharp-ean13-vector-image-svg.svg");
barcode.ImageFormat = BLImageFormat.EPS;
barcode.drawBarcode("C://BarcodeLib//csharp-ean13-vector-image-eps.eps");

EAN-13 in SVG image format viewed in Chrome web browser


EAN-13 in EPS image format viewed in Adobe Acrobat




Create EAN13 Barcodes in C# ASP.NET Web Project

  1. Add Barcodelib.Barcode.ASP.NET.dll to your web project.
  2. Add Barcodelib.Barcode.ASP.NET.dll to Toolbox.
  3. Open the folder barcode in the downloaded trial package and copy files "linear.aspx", "linear.aspx.cs" to the folder where your web project is created.
  4. Drag LinearASPNET from the Toolbox and drop it on the split part of your aspx page. Then you will see a barcode image. (Note: the SDK default barcode image is Code 128.)
  5. Click the produced barcode image, then change barcode type to EAN13 and its data to 12 digits in the Properties Window or generate EAN-13 barcode with the above C# sample codes.




Generate EAN13 Barcodes in C# WinForms

  1. Add BarcodeLib.Barcode.WinForms.dll from the downloaded trial package to your WinForms Project.
  2. Add BarcodeLib.Barcode.WinForms.dll to your Visual Studio Toolbox.
  3. Drag LinearWinForm to your windows form and you will see a Code 128 barcode image. Click the image and adjust its type to EAN13 in the Properties Window or create this linear barcode with above C# free sample codes.




Supported Barcode Formats

C# 1D Barcode Generation:
C# 2D Barcode Generation:
Barcode Generator Control for C# - Creates Linear Barcode Images: Codabar, Code 11, Code 2 of 5, Code 39, Code 93, EAN-8, EAN-13, Interleaved 2 of 5, ITF-14 (UPC Shipping Container Symbol), Code 128, EAN 128/GS1 128, MSI Plessey, Intelligent Mail, Planet, Postnet, RM4SCC (British Royal Mail), UPC-A, UPC-E.
Barcode Generator Control for C# - Creates 2D Barcode Images: Data Matrix, PDF 417, QR Code.