KA.Barcode for .NET Suite
How to Generate Code 39 in C# Application
How to Generate Linear Code 39 Barcode Images in C#, ASP.NET, WinForms, Crystal & RDLC

C# Code 39 generator: create, generate Code 39 barcodes with checksum using c# class with free example. no font.

  • Automatically add checksum digit for Code 39 according to ISO+IEC+16388 specifications
  • Easily integrate into .NET applications to generate Code 39 using Visual C#.NET class library
  • Create linear Code 39 barcode in ASP.NET, WinForms, Crystal Reports and RDLC Reports, etc
  • Support Code 128, EAN-13, EAN-128, UPC-A, UPC-E, Data Matrix and many other barcode types
  • Make scannable 1D Code 39 barcode images with high resolution that can be printed by almost all printers
  • Provide detailed user guide to help customers generate Code 39 barcode images in C#.NET
C# Code 39 Barcode Generator Overview
KA.Barcode Generator for .NET Suite is an outstanding barcode encoder component SDK which helps developers easily add barcoding features into .NET. This encoder component supports Code 39 barcode generation in C#.NET as well as other 1D and 2D barcode symbologies. And you can also customize the generated barcode images.
What Is A Code 39 Barcode
Code 39, also named as 3 of 9 Code, USD-3, Alpha39, Code 3/9, Type 39, USS Code39, is a self-checking linear barcode which encodes alphanumeric data. Code 39 is widely used in non-retail industries.
Code 39 Valid Data Sets
Code 39 encodes:
  • 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

  • Uppercase letters (A - Z)

  • - (Dash), $ (Dollar), % (Percentage), (Space), . (Point), / (Slash), + (Plus)

Code 39 extension encodes:
  • all 128 ASCII characters
Generate Barcode Image in Specified Width and Height
  • Set property AutoSizeAdjust to true

  • Set property DPI to be the same or higher as your printer's resolution

  • Set property BarcodeUnit to inch or cm

  • Set property BarCodeWidth and BarCodeHeight to your required image width and height
Code 39 Property Settings
Class Attribute HTTP Attribute Default Value Note
Symbology symbology Code128Auto Barcode symoblogy type
CodeToEncode code-to-encode "128" Barcode value to encode.
ChecksumEnabled checksum-enabled false ChecksumEnabled property is optional. Modulo 43 will be applied, if ChecksumEnabled property is true.
ImageFormat image-format ImageFormat.Png Barcode encoded image format.
Barcode Size
AutoSizeAdjust auto-size-adjust false If true, barcode X, Y module will be auto-adjusted.
BarcodeUnit barcode-unit BarcodeUnit.Pixel Unit of measure for all size related settings. 0: pixel; 1: inch; 2: cm.
X x 1 Barcode module width (narrow bar).
Y y 50 Linear barcode bar height / 2D barcode module height.
LeftMargin left-margin 0 Barcode image left margin.
RightMargin right-margin 0 Barcode image right margin.
TopMargin top-margin 0 Barcode image top margin.
BottomMargin bottom-margin 0 Barcode image bottom margin.
DPI dpi 72 Barcode image resolution in dpi.
Orientation orientation Orientation.Degree0 Barcode rotation angle.
BarCodeWidth barcode-width 0 Whole barcode width.
BarCodeHeight barcode-height 0 Whole barcode height.
Barcode Text Style
DisplayText display-text true Set to true, displaying barcode value text, otherwise do not display.
DisplayChecksum displace-checksum true Set to true, displaying barcode checksum digit, otherwise do not display.
TextFont text-font new Font(" Arial", 10 f, FontStyle.Regular) Barcode text font style.
TextMargin text-margin 6 Margin between barcode and text.
Code 39 Specific Settings
DisplayStarStop display-start-stop true Set to true, displaying Code 39 Start and Stop character (*).
I i 1.0f Code 39 inter-characters space. It抯 a multiple of X.
WideNarrowRatio wide-narrow-ratio 2.0f Code39 wide bar width vs narrow bar width ratio.
How to Generate Code 39 in ASP.NET Using C#
This barcode control dll for .NET allows developers to create and stream Code 39 linear barcode images in ASP.NET web applications. You can add this control to Toolbox and drag it to ASP.NET web page for Code 39 generation. Or you can add it to reference and create Code 39 through C# Class Library. Still, you can create Code 39 image in Microsoft IIS through URL without using Visual Studio. See: How to print barcode in Visual C# with ASP.NET web control.
How to Create Code 39 in .NET Windows Forms Using C#
For users who want to create Code 39 in .NET Windows Forms applications, they can turn to this barcode generator SDK. What provided are two methods for Code 39 creation: barcode control drag-and-drop from Toolbox or Visual C# class library & console applications after adding reference. Please refer to How to create barcode in .NET WinForms with Visual C#.
How to Embed Code 39 in Crystal Reports Using C#
KeepAutomation barcode generator for .NET Suite allows developers to easily add Code 39 barcode images in Crystal Report without installling barcode fonts, plugins, or any third party tool. This barcode control is quite easy to install and it provides a wide range of Code 39 settings to customize. Please check out the detailed guide to learn more: How to create barcode in Crystal Reports with Visual C#.
How to Add Code 39 in RDLC Reports Using C#
Developers can also print and make Code 39 barcode images in ReportViewer RDLC Local Report with this barcode generator library. Written in pure C# code, this control supports .NET Visual Studio 2005/2008/2010. For a barcoding test, download a free demo and refer to the detailed RDLC Reports C# guide: How to create barcode in RDLC Reports with C# code
How to Generate Code 39 in .NET Applications with C#
To generate Code 39 linear barcode images in Visual C# class library, you only need to add this barcode control to your project reference at first, and then copy the following C# sample code to your barcoding project for a test! All Code 39 barcode settings below are adjustable.
C# Sample code
     BarCode code39 = new BarCode();
code39.Symbology = KeepAutomation.Barcode.Symbology.Code39;

//Code 39 Encodable Character Set: Alphanumeric data:
0-9, A-Z, space $ % + - . and Start/sop character *.

code39.CodeToEncode = "6663";

// Apply checksum for Code 39 barcode.
code39.ChecksumEnabled = true;
// Display Code 39 checksum in the human-readable text
code39.DisplayChecksum = true;

//Set Code 39 image size

// Code 39 unit of measure, Pixel, Cm and Inch supported.
code39.BarcodeUnit = BarcodeUnit.Pixel;
// Code 39 image resolution in DPI.
code39.DPI = 72;
// Code 39 module bar width, ie. Width of the narrowest bar (X dimention), default is 1 pixel.
code39.X = 3;
// Code 39 module bar height (Y dimention)
code39.Y = 60;
// Code 39 wide bar width vs narrow bar. Valid from 2.of-3.0f inclusive.
code39.WideNarrowRatio = 2.0f;
// Space between character symbol, a multiple of X.
code39.I = 1.0f;

// Left margin size, a 10X space is automatically added according to specification.
code39.LeftMargin = 0;
// Right margin size, a 10X space is automatically added according to specification.
code39.RightMargin = 0;
code39.TopMargin = 0;
code39.BottomMargin = 0;
// Code 39 image orientation: 0, 90, 180, 270 degrees supported
code39.Orientation = KeepAutomation.Barcode.Orientation.Degree0;

//Set Code 39 human readable text style

// Display human readable text
code39.DisplayText = true;
code39.TextFont = new Font("Arial", 10f, FontStyle.Regular);
// Space between barcode and text
code39.TextMargin = 6;
// Print Code 39 Start & Stop Char *in barcode text
code39.DisplayStartStop = true;
// Print Code 39 barcodes in Png, Jpeg, Gif, Tiff, Bmp, etc. image formats.
code39.ImageFormat = ImageFormat.Png;

// Generate and save Code 39 barcodes to image format

/* Create Code 39 barcodes in Stream object
code39.generateBarcodeToStream(".NET System.IO.Stream Object");

Draw & Print Code 39 barcodes to Graphics object
code39.generateBarcodeToGraphics(".NET System.Drawing.Graphics Object");

Generate Code 39 barcodes & write to byte[]
byte[] barcodeInBytes = code39.generateBarcodeToByteArray();

Generate Code 39 barcodes & encode to System.Drawing.Bitmap object
Bitmap barcodeInBitmap = code39.generateBarcodeToBitmap();