How to print barcode labels from your program

Sometimes you need to print labels from a program you are writing. Here’s a few tricks to make that job easier.

You can develop a label format in its native language of IPL, ZPL, Direct Protocol, etc (there’s a bunch of them) but an easier method is to use a design tool, which are available for free from printer manufacturers and capture its output.  For Intermec printers you can download Bartender UltraLite from the Honeywell web site here. You’ll need to sign up to get an account and you’ll have to use their download tool, which works with Windows 7 but not 10.

Next, download the appropriate printer driver for your target printer. You can get these from the same Honeywell site or from Seagull Scientific.

Once you have the software and driver installed, use Bartender to design your label:

Print your label to check that it looks the way you want and you can then print your template to disk for later inclusion into your code.

Find the printer driver and open the Printer Properties page. Click on the Port Tab and change the Port to “File”:

Now print your label from Bartender again. A dialog box will pop up asking you for a file name and location to save the output. Once this is done you can open the file with a text editor and look at the data. The label above created this output file:

<xpml><page quantity=’0′ pitch=’50.8 mm’></xpml>’Seagull:2.1:DP
INPUT OFF
VERBOFF
INPUT ON
SYSVAR(48) = 0
ERROR 15,”FONT NOT FOUND”
ERROR 18,”DISK FULL”
ERROR 26,”PARAMETER TOO LARGE”
ERROR 27,”PARAMETER TOO SMALL”
ERROR 37,”CUTTER DEVICE NOT FOUND”
ERROR 1003,”FIELD OUT OF LABEL”
SYSVAR(35)=0
OPEN “tmp:setup.sys” FOR OUTPUT AS #1
PRINT#1,”MEDIA,MEDIA SIZE,XSTART,0″
PRINT#1,”PRINT DEFS,PRINT SPEED,200″
CLOSE #1
SETUP “tmp:setup.sys”
KILL “tmp:setup.sys”
CLIP ON
CLIP BARCODE ON
LBLCOND 3,0
<xpml></page></xpml><xpml><page quantity=’1′ pitch=’50.8 mm’></xpml>CLL
OPTIMIZE “BATCH” ON
PP373,698:AN7
BARSET “CODE128C”,2,1,6,203
PB “12345678”
PP474,495:NASC 1252
FT “Dutch 801 Roman BT”
FONTSIZE 12
FONTSLANT 0
PT “12345678”
PP325,297:PT “Sample Text”
LAYOUT RUN “”
PF
PRINT KEY OFF
<xpml></page></xpml><xpml><end/></xpml>

You can get rid of of the overhead and just keep the portion that actually prints the label:

PP373,698:AN7
BARSET “CODE128C”,2,1,6,203
PB “12345678”
PP474,495:NASC 1252
FT “Dutch 801 Roman BT”
FONTSIZE 12
FONTSLANT 0
PT “12345678”
PP325,297:PT “Sample Text”
PF

You can replace the two fixed text fields “12345678” and “Sample Text” with variable names and include it in your code.

You can test print the small file above by making an FTP connection from a command line to the printer and use PUT to sendthe label format to location PR1. As an example:

One label printer after the PUT command. Hope this helps.