Unsolved ZPL printing via QPrinter on Zebra printer
-
I want to print a label on a Zebra printer in form of ZPL code. That means sending Zebra Programming Language commands in form of ASCII text to the printer, or its port.
Printing from Notepad application works, not from my Qt application. Many posts followed, many things tried out, none worked for me. The closest I got is the following:
QTextDocument doc; doc.setPlainText("^XA^FO10,10^FDHelp!^FS^XZ"); //for debugging only qDebug() << "labelPrint:" << doc.toPlainText(); QPrinter printer; printer.setOutputFormat(QPrinter::NativeFormat); //printer.setOutputFileName("output.txt"); doc.print(&printer);
I do not get anything from the printer. If I save it to the file (uncommenting a line with "output.txt"), I get 1B file.
Does anybody have an idea to try out (Qt only)?
Can anybody confirm that it is not possible to get ASCII text, or bytes only through QPrinter?
I am trying also to copy or send ZPL (QString or as a file) to virtual USB002 port, but no luck yet. Advices are welcome.
Printer model Zebra GX430t, usb connected.
Driver: ZPL version, made by Seagull, comes with Bartender application.
Printer is installed as "Generic / Text Only" printer to the USB002 virtual printing port; installed also as a regular Zebra printer as well.System: Windows 7, Qt 5.7.1
-
Hi,
Is it a serial port ? If so, did you try QSerialPort and write the command to it directly ?
-
Probably it is not. If I list all available ports, only COM1: is there. I cannot open USB001 port, it does not exist, or I need better way, but I doubt.
-
Isn't this thread a bit a duplicate of this one ?
-
This topic aims to use QPrinter, and I am trying to get the confirmation that there is no way to use QPrinter and accomplish zpl printing.
The other topic is related to the copy/batch workaround to the same problem. But that is not the preferred way. That's why I created separate topics.
-
@AleksM
QPrinter wont be your way to go. Since you would need somehow translate the paint commands to ZPL code (which is definitely not in the scope of Qt).Most ZPL printers - when connected to the network - accept TCP connections and are waiting the plain ZPL data. So if thats the case for you you can simply connect to the printer's ip address (uisng QTcpSocket) and directly write the ZPL code to the socket. The printer starts printing by itself.
@AleksM said in ZPL printing via QPrinter on Zebra printer:
If I list all available ports, only COM1: is there. I cannot open USB001 port
There, USB devices also open up COM ports. So what exactly makes you so specific to the "USB001" port?
I don't know if the the simply mentioned network approach also works for the serial connection the same way.
-
@raven-worx said in ZPL printing via QPrinter on Zebra printer:
o ZPL c
QTcpSocket is an option, indeed. It works for me with batch script and a copy command inside. I will try it out.
USB001 is the port that is automatically installed with assigned to the printer, so my guess is to use that one.
-
Hello @AleksM, I'm just facing same issue. How did you solve? Thank you
-
Did anyone ever solve this problem as I have the same issue?
-
@imp1953 Are you sure you have to use ZPL?
I used GX420/430 with QPrinter for barcodes on Windows 7/10 and macOS. The trick was (after making sure that page settings are correct, which can be non-trivial on Mac) to use correct Code39 font.