Barcodes

Code 3 of 9 Barcodes

code39.png

I acquired the Code 3 of 9 algorithm from Ed Rickman at the Research Triangle Institute in 1991 while I was working for Computer Sciences Corporation under contract to the U.S. EPA on a project to redesign the database for the Radon Measurement Proficiency (RMP) Program. CSC and EPA used it to barcode mailing labels for participants in the program.

The source code was developed as C++, but it is really just plain old C. There’s nothing object-oriented about it.

Feel free to take the C/C++ code and modify it to suit your needs. That’s what I did with the Pascal code that Ed gave me.

Note: You can print barcodes, including Code 3 of 9 barcodes, just by acquiring the right fonts for your computer (e.g., openfontlibrary.org). Don’t waste time programming your own barcodes if a new font will meet your needs. I produced the barcode shown above using a free TrueType font made by IDAutomation and downloaded from openfontlibrary.org. I made it a PNG image rather than use the font itself here and worry about licensing restrictions and browser compatibility issues.
File Description
barcode.zip Zipped file containing the source code
code39.h Header file for the Code 3 of 9 functions
text39.h Header file for digitized text functions
hpbar.h Header file for printing barcodes on a PCL® printer
code39.cpp C++ source for encoding text strings as Code 3 of 9 barcodes
text39.cpp C++ source code for encoding text strings in a bit-mapped font, which can be combined with a Code 3 of 9 barcode
hpbar.cpp C++ source code for displaying barcodes (with text) on a PCL printer

By the way, the original postal barcodes (POSTNET) are even simpler than Code39. (There are only 10 characters.) If you like mathematical and logical puzzles, and you don’t already know the encoding algorithm for POSTNET, try figuring it out just by looking at several examples (if you can still find them).