Test in production without watermarks.
Works wherever you need it to.
Get 30 days of fully functional product.
Have it up and running in minutes.
Full access to our support engineering team during your product trial
Barcode labels are crucial in inventory management, product tracking, and supply chain operations. In this article, we will learn barcode printing in VB.NET using IronBarcode. Whether you’re a seasoned developer or just starting, we’ll explore the ways of creating and printing barcode labels efficiently. From designing label templates to handling printer settings, our step-by-step approach will empower you to generate accurate and visually appealing labels for your business needs.
Before we dive into the technical details, let’s understand why barcode labels matter:
VB.NET is a powerful and versatile programming language, perfect for automating tasks like label printing. However, it doesn't have built-in barcode generation capabilities. That's where IronBarcode comes in, a library that provides all the barcode-related functionalities. Integrate it into your project, and you're ready to utilize the barcode power!
IronBarcode is a powerful .NET library that simplifies barcode generation and manipulation. Whether you’re building inventory management systems, retail applications, or supply chain solutions, IronBarcode provides a seamless way to create, read, and print barcodes. With support for various barcode symbologies (such as Code 39, QR codes, and UPC), customizable settings, and straightforward integration into your VB.NET or C# projects, IronBarcode empowers developers to handle barcode-related tasks efficiently. Its intuitive API allows you to generate accurate and visually appealing barcode labels, enhancing data accuracy and streamlining business processes.
We will write the code to generate and print barcodes in a VB.NET project. First, you need to create or open a VB.NET project, then install the IronBarcode library. I will use a Console Application for this example; however, you may use any project type as per your requirements as this code works for all project types.
To seamlessly integrate the IronBarcode library into your project via the Package Manager Console, follow this step-by-step procedure for a smooth installation process:
In the console, type the following command and press Enter:
Install-Package Barcode
Install-Package Barcode
IronBarcode is free for development purposes but requires a license to explore all its functionality.
Write the following code to generate a Barcode.
Imports IronBarCode
Module Program
Sub Main(args As String())
' Creating a barcode is simple:
Dim myBarcode = BarcodeWriter.CreateBarcode("123456BCX65432", BarcodeWriterEncoding.Code128)
' Save the barcode as an image:
myBarcode.SaveAsImage("myBarcode.jpeg")
End Sub
End Module
Imports IronBarCode
Module Program
Sub Main(args As String())
' Creating a barcode is simple:
Dim myBarcode = BarcodeWriter.CreateBarcode("123456BCX65432", BarcodeWriterEncoding.Code128)
' Save the barcode as an image:
myBarcode.SaveAsImage("myBarcode.jpeg")
End Sub
End Module
This code simplifies the process of generating a barcode image using the IronBarcode library. It shows how to create a barcode and save it as an image, essentially turning data into a scannable picture.
Let's resize the barcode to fit into the printable area.
The following code will resize the barcode as per the provided dimension.
Sub Main(args As String())
' Creating a barcode is simple:
Dim myBarcode = BarcodeWriter.CreateBarcode("123456BCX65432", BarcodeWriterEncoding.Code128)
' Resize the Barcode:
myBarcode.ResizeTo(400, 100)
' Save our barcode as an image:
myBarcode.SaveAsImage("myBarcode.jpeg")
End Sub
Sub Main(args As String())
' Creating a barcode is simple:
Dim myBarcode = BarcodeWriter.CreateBarcode("123456BCX65432", BarcodeWriterEncoding.Code128)
' Resize the Barcode:
myBarcode.ResizeTo(400, 100)
' Save our barcode as an image:
myBarcode.SaveAsImage("myBarcode.jpeg")
End Sub
The process of creating a barcode remains the same. We just added a line to resize the image before saving. This adjusts its dimensions to be 400 pixels wide and 100 pixels tall, ensuring that it fits well within the desired space when displayed or printed.
Let's add the Barcode Value and annotation text below or above our barcode.
The following source code adds a Barcode Value and annotation text above and below the barcode, respectively.
Sub Main(args As String())
' Creating a barcode is simple:
Dim myBarcode = BarcodeWriter.CreateBarcode("123456BCX65432", BarcodeWriterEncoding.Code128)
' Resize the Barcode:
myBarcode.ResizeTo(400, 100)
' Add an annotation text above the barcode
myBarcode.AddAnnotationTextAboveBarcode("This is my test barcode generated using IronBarcode.")
' Add the actual barcode value below the barcode
myBarcode.AddBarcodeValueTextBelowBarcode()
' Save our barcode as an image:
myBarcode.SaveAsImage("myBarcode.jpeg")
End Sub
Sub Main(args As String())
' Creating a barcode is simple:
Dim myBarcode = BarcodeWriter.CreateBarcode("123456BCX65432", BarcodeWriterEncoding.Code128)
' Resize the Barcode:
myBarcode.ResizeTo(400, 100)
' Add an annotation text above the barcode
myBarcode.AddAnnotationTextAboveBarcode("This is my test barcode generated using IronBarcode.")
' Add the actual barcode value below the barcode
myBarcode.AddBarcodeValueTextBelowBarcode()
' Save our barcode as an image:
myBarcode.SaveAsImage("myBarcode.jpeg")
End Sub
The code for creating, resizing, and saving the barcode remains the same. We've added extra lines for annotation and value text.
Let's style our barcode by changing the background and barcode color.
The following code will change the background color and the barcode color.
Sub Main(args As String())
Dim myBarcode = BarcodeWriter.CreateBarcode("123456BCX65432", BarcodeWriterEncoding.Code128)
myBarcode.ResizeTo(400, 100)
myBarcode.AddAnnotationTextAboveBarcode("This is my test barcode generated using Iron Barcode.")
myBarcode.AddBarcodeValueTextBelowBarcode()
' Change the barcode's color
myBarcode.ChangeBarCodeColor(IronSoftware.Drawing.Color.DarkBlue)
' Change the background color
myBarcode.ChangeBackgroundColor(IronSoftware.Drawing.Color.Cornsilk)
' Save our styled barcode as an image:
myBarcode.SaveAsImage("myStyledBarcode.jpeg")
End Sub
Sub Main(args As String())
Dim myBarcode = BarcodeWriter.CreateBarcode("123456BCX65432", BarcodeWriterEncoding.Code128)
myBarcode.ResizeTo(400, 100)
myBarcode.AddAnnotationTextAboveBarcode("This is my test barcode generated using Iron Barcode.")
myBarcode.AddBarcodeValueTextBelowBarcode()
' Change the barcode's color
myBarcode.ChangeBarCodeColor(IronSoftware.Drawing.Color.DarkBlue)
' Change the background color
myBarcode.ChangeBackgroundColor(IronSoftware.Drawing.Color.Cornsilk)
' Save our styled barcode as an image:
myBarcode.SaveAsImage("myStyledBarcode.jpeg")
End Sub
The basic barcode creation steps remain unchanged. We've added lines to alter the appearance of the barcode with a different color.
This generates a styled barcode image. You can use the print dialogue in .NET Winforms if you're developing a Windows Forms application.
In this comprehensive guide, we've explored the essential role of barcode labels in data representation, error reduction, and supply chain optimization. Leveraging the power of VB.NET and the IronBarcode library, developers can seamlessly generate, read, manipulate, and print barcodes. The step-by-step approach covers installation, barcode generation, resizing, annotation addition, and styling, providing a versatile toolkit for creating accurate and visually appealing labels.
Whether you're a seasoned developer or just starting, this guide equips you to enhance efficiency in inventory management, sales transactions, and supply chain operations, making barcode integration a valuable asset for business applications.
IronBarcode offers a free trial for extended and production use.
Barcode labels are crucial for inventory management, product tracking, and supply chain operations. They encode essential information and streamline processes by providing instant access to relevant data, minimizing human errors, and optimizing supply chain operations.
VB.NET is a versatile programming language ideal for automating tasks like label printing. IronBarcode complements VB.NET by providing all the barcode-related functionalities, as it simplifies barcode generation and manipulation with its library.
To install IronBarcode in your VB.NET project, open Visual Studio, navigate to Tools > NuGet Package Manager > Package Manager Console, and run the command 'Install-Package Barcode' to download and install the IronBarcode package.
To generate a barcode image, you can use IronBarcode's API to create a barcode object with specified data and encoding, then save it as an image file using methods provided by the library.
Yes, you can resize the barcode image using IronBarcode. The library provides methods to adjust the dimensions of a barcode to fit specific requirements before saving it as an image.
Using IronBarcode, you can add annotation text above or below the barcode by invoking methods like 'AddAnnotationTextAboveBarcode' and 'AddBarcodeValueTextBelowBarcode' to include additional information or the actual barcode value.
Yes, IronBarcode allows you to change the barcode's color and background color using methods like 'ChangeBarCodeColor' and 'ChangeBackgroundColor' to enhance visual appeal and distinction.
IronBarcode is free for development purposes, but it requires a license for extended and production use. A free trial is available to explore all its functionalities.
IronBarcode supports various barcode symbologies, including Code 39, QR codes, and UPC, allowing developers to generate a wide range of barcode types for different applications.