[ic] Linux label printers

doug1 at ultimatepassage.com doug1 at ultimatepassage.com
Tue Jan 18 21:03:27 EST 2005

On Tue, 18 Jan 2005, Grant wrote:

>> Just about any thermal label printer will work with Linux.  We use
>> serveral old RJS barcode printers.  A few Printronix barcode printers and
>> over a dozen zebra printers.  There are really 2 issues that need to be
>> addressed.  The first issue is simply getting over the connectivity hump.
>> If you are using a serial connection, the baud rate, parity, and handshake
>> issues must all match.
>> Once this is done, the next step is to look at the programmers guide for
>> the appropriate printer.  For example to print hello world on a zebra
>> printer you need something like this:
>> A30,50,0,3,1,1,N,"Hello World"^M
>> The first byte tells the printer to use straight alpha.  The remaining
>> bytes up the the first comma provide the horizontal print position.  The
>> 50 after the first comma is the vertical print position (in dot rows, I
>> think).  The next commas  separated byte is the orientation (upside down,
>> vertical, etc), the next comma separted byte is font size, etc.  The last
>>   element is the actual text to be printed in quotes.
>> Here is a sample output to print a complete UPS Next Day air label.  The
>> lower case "b" and the characters that follow generate the 2D barcode.
>> The lines that start with an uppercase "B" generate a conventional
>> barcode.
>> M135,2,100^M
>> I8,0,001^M
>> N^M
>> R5,10^M
>> S4^M
>> D15^M
> [snip]
>> A30,1044,0,3,1,1,N,"ORDER NUMBER 2006"^M
>> A30,1066,0,3,1,1,N," P.O. NUMBER 3343844-1"^M
>> A598,1179,0,2,1,1,N,"URC 08/2001"^M
>> Bruce
> Thanks Bruce.  What about printing a digital TIF?  I could also
> convert it to another format.  I've got a perl script that does cause
> my lp0 laser printer to warm up, but it doesn't print.
> open (LABEL, "label.tif") or die "Could not open the label file. $!";
> open (PRINTER, ">/dev/usb/lp0") or die "Could not open the printer. $!";
> my $line = '';
> $line = <LABEL>;
> while ($line) {
> print PRINTER $line;
> $line = <LABEL>;
> }
> close(LABEL);
> close(PRINTER);
> I run it like 'perl print_script'.  What am I missing?
> - Grant
> _______________________________________________
> interchange-users mailing list
> interchange-users at icdevgroup.org
> http://www.icdevgroup.org/mailman/listinfo/interchange-users
Zebra printers are not capable of printing a TIF. Newer zebra printers are 
capable of printing PCX files.  Most of the older ones use a GRF format. 
The GRF format is an uncompressed pure hexadecimal data stream without any 
of the PCX header information.  The simplest way to create a GRF file is 
to parse the PCX header for the size and then strip off the first 128 

To quote my zebra users guide the format of the command to download
  graphics is:
where ~DG puts the printer into graphic mode
d = destination name dfault value R: (DRAM)
o = name of image
x = extension (always GRF)
t = total bytes
w = byte per row
data = actual data stream in uncompressed hex

Here is a small program to print a triangle:

The DGR command loads the stripped PCX file into the printers RAM. The ^XA 
marks the start the label command string.  The ^F050,50 sets the X and Y 
coordinate to 50 dots from the left and 50 dots down from the top.  The 
^XG command print the triangle prints the triangle.  The 1,1 on the end
of the XG command controls the magnfication (scaling) on the X and Y
  axis.  The ^XZ command renders the label.

This may sound complicated but once you get the hang of it, it's not too 
difficult.  The hardest part is parsing the PCX header information to get 
the PCX size and then stripping off the header information.


More information about the interchange-users mailing list