This article provides a simple way to produce Code 3 of 9 Barcodes through C#. While there are many third-party controls that offer this functionality, it is just as simple to integrate your barcodes using readily availabl barcode TrueType fonts.
The source code included in the zip file contains two classes, one is the UI to retrieve the barcode info (frmBarcode.cs), and the other is the barcode printing class (BarcodePrinter.cs). Also, for this example to work, you will need to add the TrueType Font for the barcode that is included in the source code.
I chose the 3 of 9 Barcode style (also known as a Code 39) for this example for two reasons, it is not fixed with, and it allows for both Alpha and Numeric characters. With the font included here, an asterisk (*) is used as both the start and the stop character for the barcode symbology. Without the (*) on both ends, the barcode will not scan.
For my example, I have set the barcode font size to 15 point. You are free to adjust is as needed for your application, but keep in mind that a small barcode may not be readable by all scanners and some wedge type scanners cannot read extremely wide barcodes. You will need to determine the proper size for your application.
Please note that I have set the #if DEBUG directive so that the application will only print to the PrintPreview Dialog during testing. Doing this saves greatly in both time and printer costs.
The human readable element of the barcode here is optional.
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.
Kuppurasu NagarajPosted Apr 18, 2016, 1:15 PM
Nice
Abdurahiman KcPosted Oct 4, 2014, 2:52 AM
Error 1 Program 'F:\Bourgeon\WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\WindowsFormsApplication2.exe' has more than one entry point defined: 'WindowsFormsApplication2.Program.Main()'. Compile with /main to specify the type that contains the entry point. F:\Bourgeon\WindowsFormsApplication2\WindowsFormsApplication2\Program.cs 14 21 WindowsFormsApplication2
cindy warnerPosted Jan 15, 2013, 10:30 PM
"With the font included here, an asterisk (*) is used as both the start and the stop character for the barcode symbology. Without the (*) on both ends, the barcode will not scan" I tried some controls to print Code 3 of 9, and sometimes it includes the option to remove the asterisk (*) of the generated bar code. Why?
SimonPosted Jul 12, 2012, 8:08 AM
Is this code available in VB.Net
nith rajPosted Feb 21, 2011, 1:40 AM
Thank u....
Piero LozadaPosted Oct 17, 2007, 5:03 PM
Hi James, my name is Piero im from Peru. i dont understand what you say about ...."you will need to add the TrueType Font for the barcode that is included in the source code"-Simple Barcoding In C#
Piero LozadaPosted Oct 17, 2007, 5:03 PM
Hi James, my name is Piero im from Peru. i dont understand what you say about ...."you will need to add the TrueType Font for the barcode that is included in the source code"-Simple Barcoding In C#
Piero LozadaPosted Oct 17, 2007, 5:03 PM
Hi James, my name is Piero im from Peru. i dont understand what you say about ...."you will need to add the TrueType Font for the barcode that is included in the source code"-Simple Barcoding In C#