Using Proform to Print Barcodes on Dot-Matrix Printers


We had a problem with a client - they wanted to add a barcode to an existing Bill-of-Lading report, which printed on a 3 part tractor feed form on a dot-matrix printer. The existing report was a plain text 12 pitch courier output.

And to make it more interesting, this report was run on a variety of Epson and Okidata printers, some of which did generate barcodes internally and some didn't.

Our brute force approach was to implemente a "Passthrough" option to Proform, which made it parse through the output stream, faithfully passing through the data until it found out special commands, then insert the result into the output stream.

This allowed us to take the original report, which for the sake of simplicity, looks like

one
two my Name is bubba ding ding
three
Thanks
And change it to output through Proform (output through "proform -b foo") and change the output thusly:
one !BARSET 1 3 0 ! 
two my Name is bubba   !BARCODE 5 2 0 30 123456789 !   !PUTCONTROL \ej# ! ding ding
three
Thanks
!BARSET 1 2 0 ! !BARCODE 5 2 0 30 123456789 !   2 pixels 
!BARSET 1 1 0 ! !BARCODE 5 2 0 30 123456789 !   1 pixels 
The net result of running this through Proform with the -b option is that on line two we inserted raw epson fx-80 graphics for a barcode, then we inserted the escape sequence to roll the paper back up to where it was before the barcode was printed. Then for fun we put out a couple of barcodes on the end.

Since almost every dot-matrix printer made supports epson fx-80 graphics, this gives us a fairly portable solution. And it lets you incorporate barcodes with a minimum of change to plain-text reports.

When using this mode, there is one more required field in the BARCODE command: OFFSET. (So the fields are Barcode Type, Height, Checksum, Offset, then the actual data you want to format. ) For dot-matrix printers this is how many characters to skip over from the left margin. For laser printers you can elect to leave this 0 and it will print after the prior text.

Now, remember, with dot-matrix reports, there is no cursor positioning. Putting a barcode on the left side of a report could be really interesting. Putting one off to the right usually only requires you to restore the vertial position to where it was before you did the barcode. You will need to figure that out for your printer. For our Epson compatibles it was ESCAPE j #

This same approach could be used on plain text reports going to a laser printer. Of course you would also have a dickens of a time getting the laser printer cursor back to where it was when you started. Of course, if your barcode was in the bottom right of the page, you wouldn't care, because you would be doing a page feed immediately afterwards. If your barcode had to be in the top left it would require some kind of !PUTCONTROL to clean things up afterwards.

For instance if you wanted to print a barcode on the end of a normal report, going to a laser printer, your code might look like this:

output through ( "proform -b foo | lp -d mylaserjet" ) paged.
put "Customer:John Jones ".
put "!BARSET 10 3 0 !" skip. /* Laserjet,3 dots/bar,portrait */
put "Address:123 Main Street" skip.
put "Account:123456789" skip(2).
put "!BARCODE 5 2 0 30 123456789 ! " skip.
page.