In the fast-moving world of automated systems, we come across various scenarios which ask for completing tasks with minimal human interference. This not only decreases human efforts but also makes the process less error-prone. ComponentOne Studio controls not only allow you to deliver rich, responsive and effective applications but also facilitate automation. Let's move a step further towards automated applications and generate barocde through Command Prompt using ComponentOne BarCode for WinForms.
The application will accept inputs such as the path of a text file containing data to be encoded and barcode encoding as command line parameters. With this capability, professional barcodes can be directly created by executing console application. Consider an example of generating barcodes for Product Names. The product names can be specified in a text file for the console application to create barcodes in bulk through:
Users can also integrate this barcode generation process into their enterprise workflow processes.
Firstly, the name of the text file containing the product name to be encoded will be retrieved using GetCommandLineArgs method. Further, the content of the file is loaded in a string variable.
Dim clArgs() As String = Environment.GetCommandLineArgs()
FileName = clArgs(2).ToString()
input = System.IO.File.ReadAllText(FileName)
C1Barcode supports a variety of encoding types such as Code Bar, Code128, Code39, Code93, Ean13, Ean8 etc., which can be utilized to generate barcodes which will fit your needs.
Dim BarType As C1.Win.C1BarCode.CodeTypeEnum = DirectCast([Enum].Parse(GetType(C1.Win.C1BarCode.CodeTypeEnum), clArgs(1).ToString()), C1.Win.C1BarCode.CodeTypeEnum)
bcode.CodeType = BarType
Lastly, the barcodes will be generated in PrintPage event of PrintDocument. In this event, Barcode Text and Image will be drawn on PrintDoucment using Text and Image properties of C1Barcode.
Private Sub _printPage(ByVal sender As Object, ByVal e As PrintPageEventArgs)
Dim bartext As String = String.Empty
Dim count As Integer = 1
For Each bartext In TextsToEncode
bcode.Text = bartext
Dim rcPage As System.Drawing.RectangleF = New System.Drawing.RectangleF(e.MarginBounds.X, e.MarginBounds.Y * count, 100, 30)
e.Graphics.DrawString(bartext, New System.Drawing.Font("ARIAL", 12.0F), Drawing.Brushes.Black, New System.Drawing.PointF(rcPage.X - 23, rcPage.Y - 20))
e.Graphics.DrawImage(bcode.Image, rcPage)
count = count + 1
Next
End Sub
To run this application through Command prompt, first browse to the application directory and execute following command.
Barcode_App.exe Code128 F:\\Products.txt
And yes, this is not the end. Do Code! Do Automatic! :)
In the fast-moving world of automated systems, we come across various scenarios which ask for completing tasks with minimal human interference. This not only decreases human efforts but also makes the process less error-prone. ComponentOne Studio controls not only allow you to deliver rich, responsive and effective applications but also facilitate automation. Let's move a step further towards automated applications and generate barocde through Command Prompt using ComponentOne BarCode for WinForms.
The application will accept inputs such as the path of a text file containing data to be encoded and barcode encoding as command line parameters. With this capability, professional barcodes can be directly created by executing console application. Consider an example of generating barcodes for Product Names. The product names can be specified in a text file for the console application to create barcodes in bulk through:
Users can also integrate this barcode generation process into their enterprise workflow processes.
Firstly, the name of the text file containing the product name to be encoded will be retrieved using GetCommandLineArgs method. Further, the content of the file is loaded in a string variable.
Dim clArgs() As String = Environment.GetCommandLineArgs()
FileName = clArgs(2).ToString()
input = System.IO.File.ReadAllText(FileName)
C1Barcode supports a variety of encoding types such as Code Bar, Code128, Code39, Code93, Ean13, Ean8 etc., which can be utilized to generate barcodes which will fit your needs.
Dim BarType As C1.Win.C1BarCode.CodeTypeEnum = DirectCast([Enum].Parse(GetType(C1.Win.C1BarCode.CodeTypeEnum), clArgs(1).ToString()), C1.Win.C1BarCode.CodeTypeEnum)
bcode.CodeType = BarType
Lastly, the barcodes will be generated in PrintPage event of PrintDocument. In this event, Barcode Text and Image will be drawn on PrintDoucment using Text and Image properties of C1Barcode.
Private Sub _printPage(ByVal sender As Object, ByVal e As PrintPageEventArgs)
Dim bartext As String = String.Empty
Dim count As Integer = 1
For Each bartext In TextsToEncode
bcode.Text = bartext
Dim rcPage As System.Drawing.RectangleF = New System.Drawing.RectangleF(e.MarginBounds.X, e.MarginBounds.Y * count, 100, 30)
e.Graphics.DrawString(bartext, New System.Drawing.Font("ARIAL", 12.0F), Drawing.Brushes.Black, New System.Drawing.PointF(rcPage.X - 23, rcPage.Y - 20))
e.Graphics.DrawImage(bcode.Image, rcPage)
count = count + 1
Next
End Sub
To run this application through Command prompt, first browse to the application directory and execute following command.
Barcode_App.exe Code128 F:\\Products.txt
And yes, this is not the end. Do Code! Do Automatic! :)