Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. ZPL printing via QPrinter on Zebra printer
Forum Updated to NodeBB v4.3 + New Features

ZPL printing via QPrinter on Zebra printer

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 6 Posters 4.2k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AleksM
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Is it a serial port ? If so, did you try QSerialPort and write the command to it directly ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        AleksM
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Isn't this thread a bit a duplicate of this one ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          A 1 Reply Last reply
          0
          • SGaistS SGaist

            Isn't this thread a bit a duplicate of this one ?

            A Offline
            A Offline
            AleksM
            wrote on last edited by
            #5

            @SGaist

            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.

            raven-worxR 1 Reply Last reply
            0
            • A AleksM

              @SGaist

              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.

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by raven-worx
              #6

              @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.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              A 1 Reply Last reply
              2
              • raven-worxR raven-worx

                @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.

                A Offline
                A Offline
                AleksM
                wrote on last edited by
                #7

                @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.

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  Landolfi
                  wrote on last edited by
                  #8

                  Hello @AleksM, I'm just facing same issue. How did you solve? Thank you

                  1 Reply Last reply
                  0
                  • I Offline
                    I Offline
                    imp1953
                    wrote on last edited by
                    #9

                    Did anyone ever solve this problem as I have the same issue?

                    artwawA 1 Reply Last reply
                    0
                    • I imp1953

                      Did anyone ever solve this problem as I have the same issue?

                      artwawA Offline
                      artwawA Offline
                      artwaw
                      wrote on last edited by
                      #10

                      @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.

                      For more information please re-read.

                      Kind Regards,
                      Artur

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved