Before stating you must know these following points:-
- Barcode according to WIKI is an optical machine-readable representation of data, which shows data about the object to which it attaches. Originally, barcodes represented data by varying the widths and spacings of parallel lines, and may be referred to as linear or 1 dimensional (1D). Later they evolved into rectangles, dots, hexagons and other geometric patterns in 2 dimensions (2D). Although 2D systems use a variety of symbols, they are generally referred to as barcodes as well. Barcodes originally were scanned by special optical scanners called barcode readers; later, scanners and interpretive software became available on devices including desktop printers and smartphones.
- Barcode symbols are just a windows font like Tahoma, Verdana or any other font … Here we choose another font support barcode industry like (Code 39 , 3 Of 9 barcode … etc). Notice: some of supported fonts are attached with this post.
- You have to use or import “System.Drawing” namespace.
for (double r = double.Parse(txtTopMargin.Text); r <= (double.Parse(txtLabelHeight.Text) + double.Parse(txtHorizontalSpace.Text)) * double.Parse(txtRows.Text); r += (double.Parse(txtLabelHeight.Text) + double.Parse(txtHorizontalSpace.Text)))
for (double c = double.Parse(txtLeftMargin.Text); c <= (double.Parse(txtLabelWidth.Text) + double.Parse(txtVerticalSpace.Text)) * double.Parse(txtColumns.Text); c += (double.Parse(txtLabelWidth.Text) + double.Parse(txtVerticalSpace.Text)))
e.Graphics.DrawString(“*DevMySkills*”, new Font(“3 of 9 barcode”, 14,FontStyle.Bold), Brushes.Blue, new Point((int)c,(int)r));
e.Graphics.DrawString(“\r\n” + “Knowledge Sharing “, new Font(“Tahoma”, 10), Brushes.Red, new Point((int)c,(int)r));
- General Notes:-
- txtTopMargin object represents the margin height from the top of the page or stickers roll.
- txtLeftMargin object represents the margin height from the left of the page or stickers roll.
- txtLabelHeight object represents the height of the barcode label.
- txtLabelWidth object represents the width of the barcode label.
- txtHorizontalSpace object represents the horizontal blank space between labels.
- txtVerticalSpace object represents the vertical blank space between labels.
- txtRows object represents the number of wanted rows to be printed.
- txtColumns object represents the number of wanted columns to be printed.
- Special Notes:-
- You definitely saw the asterisk (*) character before the string “DevMySkills”. This represents the barcode separators and will not appear in the print document as real character.
- There are some fonts must have start/stop characters and some other not … I know that you are asking why and how … etc. But I answered: “No ifs ands or buts about it“. I’m not going to go into the history or the encoding algorithm of Code 39 or any one of barcode fonts because that’s not what this article is about. If you want to know more about those topics you can search the web and find hundreds or thousands of articles.
- You must know that you are drawing with point unit … you will need to convert it if the user commit the centimeters as a general measurement unit like: each 1 cm = 28.35 points.
Download Barcode Example … .NET Framework 4.0