Zebra Printing with CUPS no print ZPL or EPL

37,422

Solution 1

Contrary to what others said, you don't need to specially add a raw queue.

Instead, you can submit raw files into any queue using -o raw switch:

lpr -P CupsPrinterName -o raw path/to/label.zpl

Printer name can be found over that link in CUPS:

http://localhost:631/printers/

This also works on other platforms that use CUPS, like Linux.

Solution 2

You can create a raw CUPS queue with lpadmin. Here's the command line I used:

lpadmin -p Zebra -E -v usb://Zebra%20Technologies/ZTC%20LP%202824%20Plus?serial=XXXXXX -m raw

You can also set up a raw queue using the CUPS web admin at

http://127.0.0.1:631/

Solution 3

This is a bit more comprehensive answer since I seem to be returning to this question every couple of years. To print with a Zebra or other barcode printers in Linux from command line follow these steps:

List all printer targets and find the printer you want to use:

$ lpinfo -v
network https 
serial serial:/dev/ttyS0?baud=115200 
serial serial:/dev/ttyS1?baud=115200 
network lpd 
direct hp 
direct usb://GODEX/G500?serial=162203C6 
network smb
...

Add new queue:

$ lpadmin -p godex -E -v usb://GODEX/G500?serial=162203C6 -m raw -o usb-unidir-default=true

If your printing is slow (takes long to start), please make sure you added -o usb-unidir-default=true.

Check available queues:

$ lpstat -v
device for godex: usb://GODEX/G500?serial=162203C6

Create a label (text file):

Create a file according to your printer's requirements in EPL (Zebra), ZPL (Zebra), EZPL (Godex).

Warning, certain CUPS versions might have an issue with raw files if they are under 512 bytes of length - longer files will print, while shorter will print once and then stall for a couple of minutes (looks like there is a timeout built in). A workaround is to add comments to extend it over 512 byte limit.

Example Zebra file (test.epl):

N
A20,20,0,2,1,1,N,"text"
B20,40,0,1,1,1,30,N,"aaaa-bbbb-cccc" 
P1

Example Godex file (test.ezpl):

;set portrait orientation
^XSET,ROTATION,0
;set height 20mm
^Q20,1
;set width 64mm
^W64
;start label
^L
;AA=print out text with smallest font, x=20dots, y=20dots, magnificationx=0,         magnificationy=0, gap=1dot, rotationInverse=0 (no)
AA,20,20,0,0,1,0,Some sample text
;BQ=code128, x=20dots,y=40dots,narrow_bar_width=1,wide_bar_width:2,height=30dots,rotation=0deg,readable=0(no)
BQ,20,40,1,2,30,0,0,1234-1243-43214-432141
;end label
E

Push to printer:

$ lpr -P godex test.ezpl
Share:
37,422
Andrew Lynch
Author by

Andrew Lynch

A university student pursing a Master Degree in International Relations who is learning to code in Ruby on Rails. Contributor for memeburn.com Entrepreneur @ CableKiosk.co.za

Updated on September 25, 2022

Comments

  • Andrew Lynch
    Andrew Lynch almost 2 years

    I have a Zebra GK420d connect to OS X via CUPS. However, when I send files to it that are written in ZPL or EPL they are only printed in plain text.

    Am I required to change to mode on the printer?

  • Yosem
    Yosem almost 12 years
    P.S. I have some sample epl raw file at stackoverflow.com/questions/10197991/… if you want to see what the raw file looks like.
  • Ethan
    Ethan almost 12 years
    If you don't use a raw socket, CUPS will try to render the text, then print it.
  • Paul-Sebastian
    Paul-Sebastian almost 7 years
    Thanks! I did read somewhere that the CUPS Zebra driver supports both RAW and PCL printing. Now to find out how to get a GUI application to print RAW...
  • sanmai
    sanmai over 6 years
    @ArgaPK ask another question; see a button at the top
  • peterretief
    peterretief over 6 years
    Nice answer, just to add a small bit of information, if you setup your zebra as the default printer to dont need to use the PrinterName
  • tresf
    tresf over 5 years
    CUPS allows raw ZPL commands per the other accepted and voted-up answers.
  • tresf
    tresf over 5 years
    The http://localhost:631 trick will for for macOS as well as long as you enable the web interface sudo cupsctl WebInterface=yes.