Quick to generate barcode in VB.NET class
Create barcode in image file
Using VB.NET Barcode Generator library, you can quickly create and print a barcode to an image file in your vb.net class, console, Windows Forms application.
- Create a
Linearobject for 1d barcode generation - Define the barcode encoding data in property
Data - Define the 1d barcode format in property
Type - Call method
drawBarcode()to print encoded Code 128 barcode to a png image file
Dim barcode = New Linear() barcode.Data = "Code 128" barcode.Type = BarcodeType.CODE128 barcode.drawBarcode("C://Output//vb-net-barcode-how-to-demo.png")
Print barcode in VB.NET memory object
You can also create and draw barcode to a VB.NET object (such as
You can also call method
MemoryStream, System.Drawing.Graphics) in memory, and you
can further process the barcode object.
You can also call method
public byte[] drawBarcodeAsBytes() to get the printed barcode in byte array.
Dim barcode = New Linear() barcode.Data = "ABC-123-abc" barcode.Type = BarcodeType.CODE128 Dim barcodeInStream = New MemoryStream() barcode.drawBarcode(barcodeInStream)
How to convert digits, text, binary data to barcode using VB.NET?
Convert digits, AlphaNumeric text to barcode
Convert digits and alphanumeric text to barcode using VB.NET is an easy job using VB.NET Barcode library.
You pass the encoding digits or alphanumeric text to property
Some barcode formats require fixed lengh of digits (such as EAN/UPC, ITF-14), your input barcode text should follow the rules.
The VB.NET sample source code below shows how to create an EAN-13 barcode. You need enter 12 (data only) or 13 (data and one checksum digit) digits to property
Top
Top
Top
Data, and the barcode library will automatically generate the barcode with the encoding data.
Some barcode formats require fixed lengh of digits (such as EAN/UPC, ITF-14), your input barcode text should follow the rules.
The VB.NET sample source code below shows how to create an EAN-13 barcode. You need enter 12 (data only) or 13 (data and one checksum digit) digits to property
Data
Dim barcode = New Linear() barcode.Data = "123456789012" barcode.Type = BarcodeType.EAN13 barcode.drawBarcode("C://Output//vb-net-barcode-how-to-convert-digits-barcode.png")
Encode barcode with ASCII chars, Unicode text, GS1, binary data
Besides simple digits and alphanumeric characters encoding, 2d barcodes and some linear barcode (such as Code 128)
supports special data encoding such as binary data, non-printable chars, Unicode, GS1 data messages.
View details here:
How to generate barcode with ASCII chars, Unicode text, GS1, binary data encoded using VB.NET?
How to generate barcode with ASCII chars, Unicode text, GS1, binary data encoded using VB.NET?
Generate and customize barcode dimension width and height in VB.NET
Quick to customize printed Code 128 barcode image width & height
You can quickly customize and draw barcode with specified image width and height in VB.NET class.
The VB codes below explains how to create and draw a Code 128 barcode image with width in 250 pixels, height in 150 pixels.
The VB codes below explains how to create and draw a Code 128 barcode image with width in 250 pixels, height in 150 pixels.
- Set barcode image dimension width size (in pixel by default) through property
BarcodeWidth - Set barcode image dimension height size (in pixel by default) through property
BarcodeHeight
Dim barcode = New Linear() barcode.Data = "ABC-123-abc" barcode.Type = BarcodeType.CODE128 barcode.BarcodeWidth = 250 barcode.BarcodeHeight = 150 barcode.drawBarcode("C://Output//vb-net-barcode-how-to-barcode-size.png")
More options to customize barcode image size
Using VB.NET Barcode Generator library API, you can further customize the printed barcode appearance through the following properties in vb codes.
- AutoResize. If it is true, the barcode library will ignore property
XandY, and the library will calculate and use the maximum bar module width and height - UOM. Unit of measure. You can choose inch, cm, or pixel (default).
- X. Bar/space module width. The property will work, if
AutoResizeis false. - Y. Bar/space module height. The property will work, if
AutoResizeis false. - LeftMargin, RightMargin, TopMargin, BottomMargin. Barcode image margins.
- BarAlignment. Barcode alignment in the image.
Dim barcode = New Linear() barcode.Data = "ABC-123-abc" barcode.Type = BarcodeType.CODE128 barcode.AutoResize = False barcode.UOM = UnitOfMeasure.PIXEL barcode.BarcodeWidth = 250 barcode.BarcodeHeight = 150 barcode.Resolution = 300 barcode.X = 1 barcode.Y = 80 barcode.LeftMargin = 0 barcode.RightMargin = 0 barcode.TopMargin = 0 barcode.BottomMargin = 0 barcode.BarAlignment = AlignmentHori.Center barcode.drawBarcode("C://Output//vb-net-barcode-how-to-barcode-size-detailed.png")
Advanced Barcode Generation and Customization in VB.NET
1D barcode text label customization
Using VB.NET barcode library, you can generate and customize linear (1d) barcode human readable text styles, such as font family, font size, font style, and text and barcode margin space.
- TextFont. You can specify the font name, size, style through
Fontobject. - TextColor. Specify the text color in RGB
- TextMargin. Margin space between text and barcode.
Dim barcode = New Linear() barcode.Data = "123456789012" barcode.Type = BarcodeType.EAN13 barcode.AutoResizeBarcodeText = False barcode.TextFont = New Font("OCR-b", 24.0F, FontStyle.Regular) barcode.TextColor = Color.Blue barcode.TextMargin = 5 barcode.drawBarcode("C://Output//vb-net-barcode-how-to-1d-barcode-text.png")
Barcode color and image settings
You can draw and print barcode with customize colors and image options applied.
Code 39 barcode in SVG viewed in web browser
- ForeColor. Barcode bar module color
- BackColor. Barcode space module color
- TextColor. 1D barcode text color
- OutputFileFormat. Specify the barcode output image file format, supports BMP, PNG, JPG, GIF, TIFF, SVG and EPS
Dim barcode = New Linear() barcode.Data = "CODE39" barcode.Type = BarcodeType.CODE39 barcode.ForeColor = Color.Red barcode.BackColor = Color.White barcode.TextColor = Color.Red barcode.OutputFileFormat = FileFormat.SVG barcode.drawBarcode("C://Output//vb-net-barcode-how-to-color-image-options.svg")
Code 39 barcode in SVG viewed in web browser
Print styled QR Code with logo image
Here you will learn how to insert a logo image to the center of QR Code using VB.NET.
Dim barcode = New QRCode() barcode.Data = "https://www.facebook.com" barcode.Logo = New System.Drawing.Bitmap("C://Input//facebook_logo_2021.svg.png") barcode.LogoActualSize = New System.Drawing.SizeF(600, 600) barcode.UOM = UnitOfMeasure.INCH barcode.AutoResize = True barcode.BarcodeWidth = 3 barcode.BarcodeHeight = 3 barcode.Resolution = 900 barcode.AutoResizePaddingTransparent = True barcode.OutputFileFormat = FileFormat.PNG barcode.drawBarcode("C://Output//vb-net-barcode-how-to-styled-qrcode.png")
VB.NET Barcode Generator Supported Barcode Symbology Types
Barcode Control for VB.NET - Bar Code Type Generation
- VB.NET 1D / Linear Barcodes:
- VB.NET 2D / Matrix Barcodes: Data Matrix, PDF-417, QR Code, Micro PDF-417, Micro QR Code
