KA.Barcode Generator for ASP.NET
How to Create & Resize Code 128 in ASP.NET
ASP.NET source code to generate, print Code 128 images using Barcode Generator for ASP.NET Control
  • Easy to use Code 128 generation component with full integration into .NET Framework
  • Draw, print dynamic Code 128 bar codes and save in GIF, JPG/JPEG, BMP, TIFF & PNG formats to local files
  • VB.NET EAN-8, Code 128 Excel, UPC-A .NET, Codabar VB.NET & VB.NET UPC-A can be created as well
  • Creating Code 128 barcode in ASP.NET webform and resize image with cm, inch, or pixel as the unit of measure
  • Flexible options to dynamically adjust linear Code 128 dimensions like image width and height
  • Support the width setting for surrounding margins in 1D Code 128A/ B/ C creation & implementation
  • Generate, create multiple high quality Code 128 in image formats like Png, Gif, Jpeg, Tiff, or Bmp
  • Implementing dynamic barcodes, like Data Matrix Java, PDF417 ASP.NET, Interleaved 2 of 5 .NET WinForms, ASP.NET EAN-8 in your projects
  • Automatically add checksum digit for generated Code 128 according to algorithm specified in ISO/IEC standard
  • Thermal printer support to print extremely accurate barcodes even on low-resolution printers
ASP.NET Code 128 barcode generating SDK plugin is one barcoding function of KA.Barcode Generator for ASP.NET, which supports programmatically streaming, creating Code 128 and other linear, bidimensional barcodes into ASP.NET websites/webforms/web pages. This document gives a way to resize Code 128 barcode in ASP.NET. IIS; details for other Code 128 related developer guides please link to:
1D Code 128 Barcode Structure
Code 128
Code 128 barcode (a.k.a ANSI/AIM 128, Uniform Symbology Specification Code 128, USS Code 128) is constructed of:
  • Left Quiet Zone
  • A start character
  • Message encoded
  • Check character
  • Stop Character
  • Termination bar (bar+space+bar)
  • Right Quiet Zone
Code 128 Size Setting with C#, VB.NET Class in ASP.NET

Install Code 128 Barcode Creator Component Library into ASP.NET Projects

  1. 1.
  2. 2.
    Add reference: Add "KeepAutomation.Barcode.Web.dll" to your ASP.NET project reference
  3. 3.
    Add to toolbox: To add BarcodeControl to your ASP.NET toolbox
Copy the C# or VB.NET barcoding syntax to you programs to create Code 128 in ASP.NET web pages/ webform/ website:
using KeepAutomation.Barcode.Bean;
BarCode barcode= new BarCode();
barcode.Symbology= KeepAutomation.Barcode.Symbology.Code128Auto;
barcode.CodeToEncode = "Code 128";
barcode.generateBarcodeToImageFile("C://barcode-code128-csharp.gif");
Dim barcode As KeepAutomation.Barcode.Bean.BarCode = New KeepAutomation.Barcode.Bean.BarCode

barcode.Symbology= KeepAutomation.Barcode.Symbology.Code128Auto
barcode.CodeToEncode = "Code 128"
barcode.generateBarcodeToImageFile("C://barcode-code128-vbnet.gif")

Drawing Code 128 Barcode with Specific BarcodeUnit

BarcodeUnit (URL: barcode-unit; Default: Pixel): it is the unit measurement for all size related settings in Code 128 barcodes. User may change it with "Pixel", "Inch" and "Cm". Replace sample code with following one:
barcode.BarcodeUnit = KeepAutomation.Barcode.BarcodeUnit.Pixel;
barcode.BarcodeUnit = KeepAutomation.Barcode.BarcodeUnit.Pixel

Printing Code 128 with Speficied Bar Width & Height

X (URL: x; Default: 1): it is the width of the narrow bar in Code 128 barcodes.

Y (URL: y; Default: 50): it is the height of bars in Code 128 barcodes.
barcode.X = 3;
barcode.Y = 75
barcode.X = 3
barcode.Y = 75

Generating Code 128 with Fixed BarCodeWidth and BarCodeHeight

BarCodeWidth (URL: barcode-width; Default: 0): it is the barcode width of Code 128 barcodes.

BarCodeHeight (URL: barcode-height; Default: 0): it is the barcode height of Code 128 barcodes.
barcode.BarCodeWidth = 200;
barcode.BarCodeHeight = 75;
barcode.BarCodeWidth = 200
barcode.BarCodeHeight = 75

Drawing Code 128 with Quiet Zone / Margin

TopMargin (URL: top-margin; Default: 0): it is the barcode image top margin in Code barcodes.

BottomMargin (URL: bottom-margin; Default: 0): it is the barcode image bottom margin in Code 128 barcodes.

LeftMargin (URL: left-margin; Default: 0): it is the barcode image left margin in Code 128 barcodes.

RightMargin (URL: right-margin; Default: 0): it is the barcode image right margin in Code 128 barcodes.
barcode.TopMargin = 8;
barcode.BottomMargin = 8;
barcode.LeftMargin = 6;
barcode.RightMargin = 6;
barcode.TopMargin = 8
barcode.BottomMargin = 8
barcode.LeftMargin = 6
barcode.RightMargin = 6
Code 128 Size Setting with Drag & Drop BarcodeControl
  1. 1.
    In "Choose Toolbox Items" form, click button "Browse...", and select KeepAutomation.Barcode.Web.dll
  2. 2.
    Now you'll see BarCodeControl in your toolbox
  3. 3.
    Drag and drop the BarCodeControl into the Forms and a Codabar image is generated
  4. 4.
    Find barcode setting panel, choose "Symbology" to "Code128" and write down encode data
  5. 5.
    Set "BarcodeUnit" to "Pixel"
  6. 6.
    Set "X" to 3, "Y" to 72; Set "BarcodeWidth" to 200 and "BarcodeHeight" to 75
  7. 7.
    Set "TopMargin" & "BottomMargin" to 8; and set "RightMarign" & "LeftMargin" to 6
  8. 8.
    A Code 128 barcodes with different customized size occurs
Code 128 Size Setting in Internet Information Service (IIS)
  1. 1.
    Copy folder "barcode" in your download the trial package to your IIS web application folder
  2. 2.
    Create a virtual directory, named "barcode", and link to your just copied "barcode" folder
  3. 3.
    Restart IIS and now you have successfully installed the ASP.NET Barcode Generator web application
  4. 4.
    To test it, open your web browser, and navigate to "http://localhost/barcode/barcode.aspx?symbology=7&code-to-encode=0123456789&barcode-unit=0&x=3&y=75&barcode-width=200&barcode-height=75&top-margin=8&bottom-margin=8&left-margin=6&right-margin=6"
  5. 5.
    A Code 128 barcode with customized size will be displayed