ZEBRA ZQ520 not printing images

Hi, i have a ZEBRA ZQ520 printer and i'm trying to print some images.Following this answer i've set up the language to zpl but nothing gets printed.Here is my code,

 

Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.qr);

 

ZebraPrinter printer = ZebraPrinterFactory.getInstance(PrinterLanguage.ZPL, printerConnection);

String setLanguage = "! U1 setvar \"device.languages\" \"zpl\"";

 

printerConnection.write (setLanguage.getBytes());
printer.printImage(ZebraImageFactory.getImage(bitmap), 0, 0, 300, 300, false);

 

When i don't set the language to zpl a long String of hexadecimal values gets printed.Any hints on this?

 

Tasos.

Anonymous (not verified)
Hi Tasos,A quick look at this

Hi Tasos,

A quick look at this looks correct.  One thing that might cause issues is the setLanguage string, it should be:

String setLanguage = "\r\n! U1 setvar \"device.languages\" \"zpl\"\r\n";

You can also try storing the image and printing:

Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.qr);

ZebraPrinter printer = ZebraPrinterFactory.getInstance(PrinterLanguage.ZPL, printerConnection);

String setLanguage = "\r\n! U1 setvar \"device.languages\" \"zpl\"\r\n";

String zpl  = "^XA^FO0,0^XGR:IMAGE.GRF^XZ";

printerConnection.write (setLanguage.getBytes());
printer.storeImage("R:IMAGE.GRF", ZebraImageFactory.getImage(bitmap), 300, 300);

printerConnection.write (zpl.getBytes());

I say this because then you can check the file listing to make sure the file was loaded correctly. Let me know if this helps or not.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Bryan Sanchez
I confirm that this code work

I confirm that this code work like a charm in a Zebra iMZ320 and using Xamarin.Android

Thanks DDDDD

Zebra.Sdk.Comm.BluetoothConnectionInsecure thePrinterConn = new Zebra.Sdk.Comm.BluetoothConnectionInsecure(discoveredPrinter.Address);

                        //thePrinterConn.Open();

                        IConnection connection = ConnectionBuilder.Current.Build(thePrinterConn.MACAddress);

                        connection.Open();

                        string setLanguage = "\r\n! U1 setvar \"device.languages\" \"zpl\"\r\n";

                        string zpl = "^XA^FO0,0^XGR:IMAGE.GRF^XZ";

                        IZebraPrinter printer = ZebraPrinterFactory.Current.GetInstance(PrinterLanguage.ZPL, connection);

                        // Toma pantallazo del celular la guarda en un Bitmap y lo manda a imprimir

                        var view = this.Window.DecorView;

                        view.DrawingCacheEnabled = true;

                        Bitmap bitmap = view.GetDrawingCache(true);

                        byte[] response1 = printer.Connection.SendAndWaitForResponse(Encoding.ASCII.GetBytes(setLanguage), 500, 500);

                        printer.StoreImage("R:IMAGE.GRF", bitmap, 500, 800);

                        byte[] response2 = printer.Connection.SendAndWaitForResponse(Encoding.ASCII.GetBytes(zpl), 500, 500);

                        string response1string = Encoding.ASCII.GetString(response1);

                        string response2string = Encoding.ASCII.GetString(response2);

WhatsApp Image 2017-06-20 at 11.26.21 PM.jpeg

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments