KA.Barcode Generator for .NET Suite
How to Create & Resize Code 39 in C#
Complete C# source code to generate, print Code 39 images and change barcode size with .NET Control
  • Complete C#.NET source code to generate Code 39 images and change barcode size with .NET Control
  • Compatible with ISO/IEC 16388 Code39 bar code symbology specification for valid image generation
  • Easy-to-use barcode generator provided, such as .NET barcode, barcode Word, Excel barcode & barcode Java
  • Programmatically draw linear Barcode 3 of 9 in Png, Jpg, Gif, Tiff, Bmp image formats and save to files
  • Easily adjust Code 39 property WideNarrowRatio to change bar width using C# programming
  • I dimension adjustable to customize space between symbol characters in Code 39 images
  • Simple to adjust the generated linear Code 39 barcode width and height in C#.NET
  • Provide detailed Java barcode generation, .NET WinForms barcode creation & Word barcode creation guides for users
  • Mature barcode creator component for generating, creating 3 of 9 barcodes in VS .NET
Code 39 is a linear barcode also named 3 of 9 Barcode, ASNI/AIM Code 39, USD-3, USS Code 39, Code 3/9, Code 3 of 9, USD-3, Code 39 Extended. This KA barcoding component is a reliable Code 39 creator for .NET developers to draw, make Code 39 in Visual C#.NET class library.
This page offers complete source code to generate, print Code 39 barcodes in C#.NET and adjust Code 39 through X dimension, barcode width, I dimension and other properties. Here are two more tutorials for Code 39 data and image setting.
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 Code 39 Images in C# Class
Copy the following free C#.NET sample code onto your project to produce a Code 39 barcode image
using KeepAutomation.Barcode.Bean;

BarCode code39= new BarCode();
code39.Symbology = KeepAutomation.Barcode.Symbology.Code39;
code39.CodeToEncode = "CODE39";
code39.X =2;
code39.generateBarcodeToImageFile("C:/code39_csharp.png");

code39_image

Code 39 Barcode Unit

The default value for Code 39 barcode unit is pixel for KA.Barcode Generator for .NET Suite, so all the parameters below, like X dimension, barcode width, etc are measured in pixel. To create Code 39 using Cm or Inch, simply copy the C# demo code below.
code39.BarcodeUnit = BarcodeUnit.Cm;
Visual C#.NET. How to Generate Barcodes in Crystal Reports Using C#. ....
Unzip. KeepAutomation provides barcode generation tutorial or example for users. How to Drag & Drop QR Code Generator Addin in .NET. ....
Code written in Visual Basic.NET, easy ....
JPEG/JPG, BMP, PNG, to save QR Code barcode image in your VB.NET applications. ....
more>

Code 39 X Dimension (Module Width)

Code 39 X dimension is the width of the narrow element, i.e. width of the module bar. Default value is 1 pixel. Users can adjust this parameter according to your needs. The greater the X dimension, the wider the bar code image is.
code39.X = 3;  

Code 39 WideNarrowRatio

Code 39 WideNarrowRatio stands for the ratio of Code 39 wide bar width to Code 39 narrow bar width, which is valid from 2 to 3 inclusive, as is specified in Code 39 standard. For example, if you set X to 2 pixels, and WideNarrowRatio to 3, then your generated Code 39 wide bar width would be 6 pixel. You can easily adjust this dimension through the following C# code.
code39.X = 2;
code39.WideNarrowRatio = 3;

Code 39 Y Dimension (Bar Height)

Code 39 Y dimension is the height of Code 39 bar, as well as the height of the whole code 39 bar code image. This is a float value is 50 pixels by default. You can adjust Code 39 bar height through the C#.NET code below.
code39.X = 2;
code39.WideNarrowRatio = 3;

Code 39 I Dimension

I Dimension is the intercharacter space in a generated Code 39 bar code image. This property is float with a default value 1, which is the minimum value as is required in Code 39 specification. It means the intercharacter space is equal to X. For example, if you set X to 2 pixels, and I dimension to 1.5, then the intercharacter space is actually 1.5 times of X dimension, which finally comes to 3 pixels.
code39.I = 1.5F;

Code 39 Barcode Quiet Zones / Margins

It is clearly defined in the ISO/IEC 16388 Code 39 bar code symbology specification that the quiet zones / margins at the left and right side of a Code 39 image shall be a minimum of 10X (10 times the width of the module bar). KeepAutomation C# Code39 generator will automatically calculate and add this 10X quiet zones for you. If you want to add more margins on four sides, just follow the codes.
code39.LeftMargin = 3;
code39.RightMargin = 3;
code39.TopMargin = 3;
code39.BottomMargin = 3;

Code 39 BarCode Height and BarCode Width

With KA.Barcode Generator for .NET Suite, users can also customize Code 39 barcode width and barcode height easily using Visual C#.NET programming. You can copy the C# demo code below into your projects for testing.
code39.BarCodeHeight = 60;
code39.BarCodeWidth = 175;
Please note that once you have input Code 39 data and adjusted X dimension, there will be a minimum image width according to the encoding pattern specified in the standard. Thus if the barcode width you are trying to set is less than that minimum value, this value will be considered to be invalid.

KA.Barcode Generator for .NET Suite will generate a valid Code 39 image with the minimum barcode width. You will have to either assign a greater value to BarcodeWidth or set X dimension smaller.

Code 39 TextMargin

Code 39 Text Margin is the margin between the Code 39 human readable text and the bottom of the bars. Default is 6 pixels. You can simply adjust this parameter through the following setting.
code39.TextMargin = 6;