C#. Code 128 Generator Size Setting Tutorial
sample source code to generate linear Code 128 images and adjust barcode size in C# .NET
- Easy to integrate Code 128 barcode generation component into your C#.NET Programs
- Provide 100% C#.NET source code and strong named assemblies
- Support to create all ASCII characters using Code 128 subset A, subset B and subset C
- Show or hide Code 128 human-readable characters with customize margin, color and font style
- Simple to adjust Code 128 barcode size by modifying Code 128 barcode width & height, Code 128 bar width & height, barcode margin, etc
- Draw Code 128 barcode compatible with the latest Code 128 specification - ISO / IEC 15417 (2nd edition 2007-06-01)
- Mature Code-128 barcode generating components used by 1000+ clients
- Tutorial for Code-128 Image Setting in Visual C#.NET
- Tutorial for Code-128 Data Encoding in Visual C#.NET
Code 128, also known as ANSI/AIM 128, ANSI/AIM Code 128, USS Code 128, Uniform Symbology Specification Code 128, is a very capable linear barcode of excellent density, high reliability.
How to generate, print barcode using .NET, Java sdk library control with example project source code free download:
Code 128 Structure
Code 128 Image Width Related Settings
W: the barcode width of Code 128. It equals to 11X (C + D/2) + 2Q + 2X. Please see BarCodeWidth.
C: the number of symbol characters (including symbol check character)
X: the width of a module bar; Xmin=1 pixel. Please see X.
Q: the width of the quiet zone; Qmin=10X. Please see Left & Right Margin.
D: the number of numeric data characters encoded in double density (Code Set C)
Code 128 Image Height Related Settings
H: the barcode height of Code 128. Please see BarCodeHeigth.
Y: the height of a module bar. Please see Y.
Top & Bottom Margin: the height of the top & bottom margin. Please see Top & Bottom Margin.
Text Margin: the space between image bar and text. Please see TextMargin.
Text Font: the font style of human-readable text. Please see TextFont.
Setting Code 128 Barcode Size in C#
C# Code 128 barcode provides a set of barcode size settings to specify you Code 128 barcodes. Please download C# barcode component and install, copy those following code to your Visual Studio:
Linear barcode = new Linear();
barcode.Type = BarcodeType.CODE128;
barcode.Data = "ONBARCODE";
Modify your Code 128 barcodes by setting those following properties:
UOM
UOM is short for Unit of Measure, which is the unit of measure for all size related settings in the library. C# 128 barcode provides 3 options: Pixel, Cm, and Inch. The default is Pixel.
barcode.UOM = UnitOfMeasure.PIXEL;
Barcode Width & Height
BarcodeWidth is the Code 128 barcode image width. The default in C# Code 128 barcode is 0 (float).
BarcodeHeight is the Code 128 barcode image height. The default in C# Code 128 barcode is 0 (float).
barcode.BarcodeWidth = 0;
barcode.BarcodeHeigth =0;
Notice: if your setting is smaller than the barcode required minimum width and height, the library will automatically reset to barcode minimum width. Or you may enable AutoResize to automatically resize your Code 128 barcode image.
Barcode Margin
BarcodeMargin is the white zone around the Code 128 symbol. C# Code 128 barcode provides 4 options: Left Margin, Right Margin, Top Margin and Bottom Margin. The default of these four margins are 0 (float).
barcode.TopMargin = 3;
barcode.BottomMargin = 3;
barcode.LeftMargin = 1;
barcode.RightMargin = 1;
X & Y
X is the width of barcode bar module (narrow bar). The default in C# Code 128 barcode is 1 (float).
Y is the height of barcode bar module. The default in C# Code 128 barcode is 60 (float).
barcode.X = 2;
barcode.Y = 80;
Text Margin & Font
TextMargin is the space between barcode and barcode data text. The default in C# Code 128 barcode is 6 (float).
TextFont is the font style of human-readable text. The default in C# Code 128 barcode is new Font ("Arial", 9f, FontStyle.Regular).
barcode.TextMargin = 9;
barcode.TextFont = new Font("Arial", 20f, FontStyle.Regular);