Generate Barcode - Vb.net

How to Generate Barcode?

Snippet Code


  
Rate this page :
  [ 0 votes]

This Technical tip explains how .NET developers can generate barcode using custom width support inside their applications using Aspose.BarCode for .NET. Originally, barcodes systematically represented data by varying the widths and spacing’s of parallel lines. Now, you can generate and recognize barcodes with custom widths. The idea is to calculate the widths for all supported properties and generate a barcode that fits in the space left.

// Code sample for creating an Image with Exact Barcode Only //[C# Code Sample] // Generate the barcode BarCodeBuilder builder = new BarCodeBuilder(); // Set symbology type builder.SymbologyType = Symbology.Code128; // Set the code text builder.CodeText = "123456"; // Get bitmap with exact barcode only Bitmap bmp = builder.GetOnlyBarCodeImage(); // Save image on local bmp.Save("c:\barcode.png", ImageFormat.Png); //[VB.NET Code Sample] ' Generate the barcode Dim builder As New BarCodeBuilder() ' Set symbology type builder.SymbologyType = Symbology.Code128 ' Set the code text Dim codetext As String = "123456"; builder.CodeText = codetext ' Get bitmap with exact barcode only Dim bmp As Bitmap = builder.GetOnlyBarCodeImage() ' Save image on local bmp.Save("c:\barcode.png") //Create and Set Size for Whole Picture With Barcode inside //[C# Code Sample] // Generate the barcode BarCodeBuilder builder = new BarCodeBuilder(); // Set symbology type builder.SymbologyType = Symbology.Pdf417; // Set the code text builder.CodeText = "One thing 2 thing"; // Set the code text location builder.CodeLocation = CodeLocation.None; // Set graphics unit builder.GraphicsUnit = GraphicsUnit.Pixel; // Set margins builder.Margins.Set(0); // Get Bitmap with exact barcode only Bitmap bmp = builder.GetOnlyBarCodeImage(); // Allows to set size for whole picture with barcode inside Bitmap tt = builder.GetCustomSizeBarCodeImage(new Size(bmp.Width * 5, bmp.Height * 5), false); // Save image on local tt.Save(@"c:abv5.2test20barcode2.png", ImageFormat.Png); //[VB.NET Code Sample] ' Generate the barcode Dim builder As New BarCodeBuilder() ' Set symbology type builder.SymbologyType = Symbology.Pdf417 ' Set the code text builder.CodeText = "One thing 2 thing" ' Set the code text location builder.CodeLocation = CodeLocation.None ' Set graphics unit builder.GraphicsUnit = GraphicsUnit.Pixel ' Set margins builder.Margins.[Set](0) ' Get Bitmap with exact barcode only Dim bmp As Bitmap = builder.GetOnlyBarCodeImage() ' Allows to set size for whole picture with barcode inside Dim tt As Bitmap = builder.GetCustomSizeBarCodeImage(New Size(bmp.Width * 5, bmp.Height * 5), False) ' Save image on local tt.Save("c:abv5.2test20barcode2.png", ImageFormat.Png)

Tags


Ask Questions

Ask Question