ARTICLE

Simple Barcoding In C#

Posted by James Divine Articles | Printing in C# September 08, 2003
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 available barcode TrueType fonts.
Reader Level:
Download Files:
 

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.

Login to add your contents and source code to this article
post comment
     

"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?

Posted by cindy warner Jan 15, 2013

Is this code available in VB.Net

Posted by Simon Jul 12, 2012

Thank u....

Posted by nith raj Feb 21, 2011

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#

Posted by Piero Lozada Oct 17, 2007

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#

Posted by Piero Lozada Oct 17, 2007
COMMENT USING
PREMIUM SPONSORS
Over-C is a holistic consortium of communications and technology specialists. We build, deploy and market both business as well as consumer products and solutions.
Join a Chapter
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Join a Chapter