HOME - - - - - Lazarus Tutorials TOC - - - - - - Other material for programmers

Create barcodes from text

An introduction. No frills.

filename: lt4Nf-Barcode.htm

This page is "browser friendly". Make your browser window as wide as you want it. The text will flow nicely for you. It is easier to read in a narrow window. With most browsers, pressing plus, minus or zero while the control key (ctrl) is held down will change the texts size. (Enlarge, reduce, restore to default, respectively.) (This is more fully explained, and there's another tip, at my Power Browsing page.)

This is one of my offerings where all of the help to programmers is in the rems inside the sourcecode... but it is extensive in this case.

The .zip also contains a "ready to run" / "standalone" .exe. It won't "install"... just use it as is. One job. One file. Simples!

If you've come here from my page about barcodes for books in a collection, I'm afraid that this page does not give you everything you would need, in one simple package. You may find it useful... I hope you do... but it isn't an advertisement for a finished product. I used to produce that sort of thing... but I found that if I spent the many hours it takes to move something from a program that does what I to a program that is useful to the general public, I tended to sell one copy ($25, as shareware)... spend hours helping the user get to grips with it... and then sell no more copies. Shortly after one or two people had paid for copies, free copies were in various places on the internet. If you are seriously wanting something to print labels from a simple text file listing Book ID, author and title, send me an email, citing "lt4Nf-Barcode.htm", and we can discuss it. But I won't be able to produce it overnight. How to get my email is explained at the bottom of this page.

The full sourcecode, and a copy of the standalone .exe are available for download as a .zip file.

Near the start of the sourcecode, you will find something that ALMOST says the following. The following is what it was meant to say...

(More good test strings: c11707a-l11707a...
     Just keep changing the first character, go
     from c to l ("ell"), and you will test that all of the "funny"
     checksum characters are being generated properly.
     The first (c11707a) should give you the tilde as
     the checksum character, which is a standard, 1-byte, ASCII

Don't be alarmedif you try this, and the result for l11707a seems to be wrong. You might... as I did for a trying 90 minutes... think that for that test string "no" checksum character was generated. The checksum in that case is a space. Duh. How many years have I been banging the "a space just another character" drum"??

The program takes text and turns it into a barcode, using the widely used "Code 128". Most characters... 0-9, a-z, A-Z, lots of punctuation... can be encoded.


You will need to have a Code 128 font on your system. I found a good one, available for free download (without registration) from https://www.wfonts.com

There are simple, free, Windows utilities for reading barcodes with a simple ($18) USB webcam...

Try either...

1) Katanshi bar code reader.  It seemed the simplest.

   Now... Firefox objected when I tried to visit...
   ... but I was able to download it (and the download passed an eSet malware
      scan) from...

   --- alternatively....

   2) the scanner-by-webcam software from...


   (You have to dig a little to find the freeware one, but I found this polished,
   quick, reliable. But remember to click the "Start" button in the "live view"
   window (!) Oh. And for this and the first one, do tell it you'll be looking
   at Code 128 barcodes.)      

If you read the barcodes with a webcam, you don't even have to create ink-on-paper barcodes... you can just point your webcam at the screen. (assuming it is on a cable, not built into the monitor that is displaying the barcode!)

If you are using a "standard" barcode scanner, you probably do need to give it an ink-on-paper image to scan. The standard readers... I bought a nice one from Amazon for less than $25... are great- they are just "keyboard wedges". (They will co-exist with your ordinary keyboard, by the way.) The "scan with webcam" software can be a little flaky. At the moment one of them does work... but it takes up to 40 seconds for the live image to appear in the scanning window after you have invoked that. (But once you have the live image, it can do scan/ scan/ scan just fine, very quickly.)

Character set revisited

Here are the ALL the characters allowed in the data portion of a barcode- when you are using Code128, sub-code B throughout ... which is, as I said, the only thing this code attempts.

(space) ! " # $ % & ' ( ) * + , - . /
   0 1 2 3 4 5 6 7 8 9
   : ; < = > ? ©
   [ \ ] ^ _ `
   { | } ~

Certain international characters, e.g. "£" CANNOT go in the data portion of the barcode.)

The set just listed in full is merely all the ASCII characters with decimal values >31 and < 127. (Exclusive. Not ">=" or "<=")

When is a character not a byte?

If you just want to use my code, without worrying too much about what's going on, that's fine.

If you do go very far into it, you need to be aware of the following...

Beware: Our computers are "being helpful" again.

In the Olden Days, it took three BYTES to display three characters. "ABC" arose from 65, 66 and 67 (decimal) being somewhere inside the computer. Broadly speaking, that is still true.

However, when we wanted "more", it came at a cost. We wanted, for instance to be able to display "©", the copyright symbol. To put that in the context I used before, A©C CAN be shown on our output devices... but it takes "UTF-8". And, in a system that "understands UTF-8... as most do today, "behind" A©C there are FOUR bytes stored somewhere: 65,194,169,67.

Search across all my sites with the Google search...

Custom Search

To search THIS site.... (Go to my other sites, below, and use their search buttons if you want to search them.)

index sitemap advanced
search engine by freefind

Site Map    What's New    Search

The search engine merely looks for the words you type, so....
*    Spell them properly.
*    Don't bother with "How do I get rich?" That will merely return pages with "how", "do", "I"....

Please also note that I have two other sites, and that this search will not include them. They have their own search buttons.

My SheepdogSoftware.co.uk site.

My site at Arunet.

Ad from page's editor: Yes.. I do enjoy compiling these things for you. I hope they are helpful. However... this doesn't pay my bills!!! Sheepdog Software is supposed to help do that, so if you found this stuff useful, (and you run a Windows or MS-DOS PC) please visit my freeware and shareware page, download something, and circulate it for me? Links on your page to this page would also be appreciated!
Click here to visit editor's freeware, shareware page.

Link to Lazarus Tutorials main page

To email this page's editor, Tom Boyd.... Editor's email address. Suggestions welcomed! Please cite "qPg.htm". ...qNO under_score in filename here.

Valid HTML 4.01 Transitional Page has been tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org. Mostly passes.

AND passes... Valid CSS!

If this page causes a script to run, why? Because of things like Google panels, and the code for the search button. Why do I mention scripts? Be sure you know all you need to about spyware.

....... P a g e . . . E n d s .....