11 Replies Latest reply on Dec 14, 2016 10:45 AM by Robin West

    [RW420 - ZQ520] Image print problem with CPCL language

    Marco Rinaldi

      For our application we use the Zebra RW420 model with the Zebra Android SDK, which allowed us to print an image using the CPCL language with the PCX command.

      We store this image on the printer because when we print a document this image could be present more than once on it.

      Using the CPCL language we call the image through the PCX command in this way:

       

      PCX [X] [Y]  !<nameFile.pcx\r\n
      

       

      However, since RW420 has been deprecated for the ZQ520 model, the same functionality does not work, and instead of printing an image, the printer prints out a lot of hexadecimal characters or a white space with the image size. Everything else works great with the new LinkOS (I just check the ZebraPrinterFactory instance for LinkOsPrinter). I also read that images are now stored in GRF format

       

      Since our algorithm is written with the CPCL language and all new printers work well with the ZPL language how is it possible to make my code working with little changes?

      Firmware of our ZQ520 is V76.19.13Z.

       

      Thanks in advance for your replies.

        • Re: [RW420 - ZQ520] Image print problem with CPCL language
          Robin West

          Hi Marco,

          You have two options, Continue to use CPCL, or switch to ZPL.

          CPCL:

          create your ZebraPrinterLinkOs using the ZebraPrinterFactory.getLinkOsPrinter(connection, PrinterLanguage.CPCL)

          Then, you should be able to use the rest of your code normally.

           

          ZPL:

          Create your ZebraPrinterLinkOs the way you have been, or use ZebraPrinterFactory.getLinkOsPrinter(connection, PrinterLanguage.ZPL)

          Store the image using the ZebraPrinterLinkOs.storeImage("E:NameFile", imagepath, -1, -1) function

          Recall and print the image using the string:

          ^XA^XGE:NameFile^XZ

            • Re: [RW420 - ZQ520] Image print problem with CPCL language
              Marco Rinaldi

              Hi Robin,

              Thank you for your reply.

               

              Unfortunately I use that method.

              First I call

              ZebraPrinterFactory.getInstance(printerConnection);

              after that I use

              ZebraPrinterLinkOs linkOsPrinter = ZebraPrinterFactory.createLinkOsPrinter(printer, PrinterLanguage.CPCL);

              to check printer (RW420 or ZQ520)

               

              I think the problem is in the storeImage() method because I send a .PCX file but ZQ520 stores a .GRF file (with the same name).

                • Re: [RW420 - ZQ520] Image print problem with CPCL language
                  Gregory Pawlik

                  Hi Marco,

                   

                  Please have a look at this Zebra Knowledge Base article on storing PCX images.

                  It explains how to create a file that will store your PCX image on the printer.

                   

                  Hope this helps.

                   

                   

                  Greg

                    • Re: [RW420 - ZQ520] Image print problem with CPCL language
                      philip koprowski

                      Hi Greg,

                       

                      The knowledge base article you provided prints the image using ZPL.

                       

                      Unfortunately, that will not work for our solution because we already have a large amount of code in CPCL that would have to be converted. Our current code already works fine with the rw420 and the new zq520 works for eveything but the image. I have confirmed that the image was loaded into memory on the printer but, like the original post stated, was turned into a grf extension. It will not print using the CPCL command that works for the rw420.

                       

                      This sounds like a firmware fix that needs to be applied as the documentation for the rq520 clearly states it is CPCL compatible.

                       

                      I will try to upload the image using this solution but I must have a way to print the image using CPCL.

                    • Re: [RW420 - ZQ520] Image print problem with CPCL language
                      Robin West

                      Hi Marco,

                      This is the code I used to store and print an image file from Android using the SDK to a ZQ520 printer:

                       

                      private void printcpcl()

                      {

                          String address = "AC:3F:A4:0C:8E:9D";

                          String cpcl = "! 0 200 200 406 1\r\nPW 588\r\nTONE 0\r\nSPEED 6\r\nSETFF 203 5\r\nON - FEED FEED\r\nNO - PACE\r\nJOURNAL\r\n";

                          cpcl += "PCX 100 134 !<nameFile.pcx\r\nT180 4 0 452 354 Text at the top\r\nT180 4 0 472 92 Text at the bottom\r\nPRINT\r\n";

                           BluetoothConnectionInsecure connection = null;

                          try

                          {

                              connection = new BluetoothConnectionInsecure(address);

                              connection.open();

                              ZebraPrinter printer = ZebraPrinterFactory.getInstance(PrinterLanguage.CPCL, connection);

                              ZebraPrinterLinkOs linkOsPrinter = ZebraPrinterFactory.createLinkOsPrinter(printer, PrinterLanguage.CPCL);

                              String path = FindPath();

                              ZebraImageI image = ZebraImageFactory.getImage(path);

                              printer.storeImage("nameFile.pcx", image, -1, -1);

                              connection.write(Encoding.ASCII.GetBytes(cpcl));

                          }

                          catch (ConnectionException e)

                          {

                              Log.Error("CPCLTEST", e.Message);

                          }

                          finally

                          {

                              if ((connection != null) && (connection.isConnected))

                                  connection.close();

                          }

                      }

                       

                      The one thing I noted is the storeImage command only works with CPCL if you call it from the ZebraPrinter object, not the ZebraPrinterLinkOs object.  The image file was a JPG file I had stored on my Android device.

                      Let me know if this helps.

                      Robin

                        • Re: [RW420 - ZQ520] Image print problem with CPCL language
                          Stephen Brennan

                          Hi Robin,

                           

                          I have tried using your code.  First of all when I try storing a PCX image I get an IOException (unknown image type).  When I store a BMP or JPG file, the code runs, but all that prints is the filename (with a GRF extension) followed by a lot of hexadecimal characters as described by Marco.

                            • Re: [RW420 - ZQ520] Image print problem with CPCL language
                              Robin West

                              Hi Stephen,

                              If you already have a PCX image file, then you don't need to do all the work of using the ZebraImageI and StoreImage to store it, you can simply embed it directly.  The code above is more for if your images are image types like JPG and BMP files.  The storeImage code attempts to convert it into a PCX and send it to the printer.  You just need to add a header:

                               

                              private void printcpcl()

                              {

                                  String address = "AC:3F:A4:0C:8E:9D";

                                  String cpcl = "! 0 200 200 406 1\r\nPW 588\r\nTONE 0\r\nSPEED 6\r\nSETFF 203 5\r\nON - FEED FEED\r\nNO - PACE\r\nJOURNAL\r\nPCX 100 134 ";

                                  String cpclEnd = "\r\nT180 4 0 452 354 Text at the top\r\nT180 4 0 472 92 Text at the bottom\r\nPRINT\r\n";

                                  BluetoothConnectionInsecure connection = null;

                                  try

                                  {

                                      connection = new BluetoothConnectionInsecure(address);

                                      connection.open();

                                      ZebraPrinter printer = ZebraPrinterFactory.getInstance(PrinterLanguage.CPCL, connection);

                                      String path = FindPath();

                                      connection.write(Encoding.ASCII.GetBytes(cpcl));

                                      printer.sendFileContents(path);

                                      connection.write(Encoding.ASCII.GetBytes(cpclEnd));

                                  }

                                  catch (ConnectionException e)

                                  {

                                      Log.Error("CPCLTEST", e.Message);

                                  }

                                  finally

                                  {

                                      if ((connection != null) && (connection.isConnected))

                                          connection.close();

                                  }

                              }

                               

                              I haven't had a chance to test this code, but it should work (let me know if it doesn't).