iMZ320/ZPL: How to use Z64 and LZ77 to compress data downloading to the printer

// Expert user has replied.
H Hartmut Neubauer 3 years 7 months ago
639 2 0

Hi, I have an iMZ320 8cm printer and I want to use it with Android devices. Usually we transform all our print data to graphics and send them to the printer; this works in our case (using ^GF for every graphics field), but it needs too much time to download all the data. Currently I use ASCII encoding with Base64 (for example: "^GFA,1152,1152,72,:B64:AAADwAAAA+AAAAAA:f113") So I thought to use compression. There is the possibility of LZ77 compression before the Base64 encoding (something like that: "^GFA,1152,1152,75,:Z64:xxxxxx:crcc").
Can anybody assist me how to implement the LZ77 algorithm? Thanks in advance.

Please Register or Login to post a reply

2 Replies

H Hartmut Neubauer

Hi,

I have now found that it is possible to use the DEFLATE algorithm. It is widely used by PKZIP, GZIP, ZLIB etc. and includes the LZ77 as well as Huffman encoding. Java and Android users can use the java.util.zip package and the Deflater class.

M Manuel Caicedo-Rivera

Hi Hartmut,

If you want to work with Android Devices, we have a powerful set of libraries, classes and interfaces that you can use immediately in your project.
For the specific use case mentioned, Zebra's API has already implemented the Z64 compression algorithm.

Zebra API for Android (build v2.9.2275)​
I have a sample code that you can use.

public interface GraphicsUtil

This is an utility class for printing images on a device.

package test.zebra.sdk.printer.examples;

import java.io.IOException;

import com.zebra.sdk.comm.Connection;
import com.zebra.sdk.comm.ConnectionException;
import com.zebra.sdk.comm.TcpConnection;
import com.zebra.sdk.printer.ZebraPrinter;
import com.zebra.sdk.printer.ZebraPrinterFactory;
import com.zebra.sdk.printer.ZebraPrinterLanguageUnknownException;

public class GraphicsUtilExample {

     public static void main(String[] args) throws Exception {
         Connection connection = new TcpConnection("192.168.1.32", TcpConnection.DEFAULT_ZPL_TCP_PORT);
         try {
             connection.open();
             ZebraPrinter printer = ZebraPrinterFactory.getInstance(connection);
             int x = 0;
             int y = 0;
             printer.printImage("/sdcard/sample.jpg", x, y);
         } catch (ConnectionException e) {
             e.printStackTrace();
         } catch (ZebraPrinterLanguageUnknownException e) {
             e.printStackTrace();
         } catch (IOException e) {
             e.printStackTrace();
         } finally {
             connection.close();
         }
     }

}

We highly recommend to avoid send a huge quantity of data during WiFi or BT connection, please, take a look to our article
Zebra Technologies - Best Practices in Creating a Printing Application for Zebra Printers

We recommend Zebra Designer tool to build your label, this tool will generate the code in ZPL for you, then you can use it in your app.

Please, let me know if you need more assistance.

Thanks,
MC

CONTACT
Can’t find what you’re looking for?