Zebra Printing with CUPS no print ZPL or EPL

2020-05-19 09:34发布

问题:

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?

回答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.



回答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/


回答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


回答4:

I am a PC guy so I don't know CUPS well, but I have used zpl and epl on PC's and found that they really like to get the raw print files. I always do a : filecopy "c:\zplfile.txt" "\computername\printershare" type command. I have used wordpad too, if I just want to do some text. But for labels and barcodes I would see if there is a way for you to send the raw zpl or epl to the printer port. Hope this helps.



回答5:

You would need to avoid any filtering. Print using a RAW filter, as configured in the CUPS interface, or by default in your lpadmin statement. You did not state how the printer was connected, but if IP, your destination would most-likely be socket://ip.addr.ess:9100.



回答6:

Thanks. I have looked at it some more. It seems that while using cups you cannot send raw ZPL commands to the printer. Like what I did was create the printer in cups as a socket and started a netcat listener on 9100 and then issued some sort of command to the printer

nc -l localhost 9100

zpl_mine="^XA ~SD10 ^PW 850 ^MM T ^MN W ^JUS ^XZ,";echo $zpl_mine | nc localhost 9100 -w 1

and this does not send the information to the printer, but I have seen on some forums that you have to use some form of language like C to parse the information