LinkOS-Android-Samples icon indicating copy to clipboard operation
LinkOS-Android-Samples copied to clipboard

Zebra Printer ZQ320 is printing Extra space after print

Open Zulqurnain opened this issue 6 years ago • 6 comments

I am tring to print an image but, provided sdk is printing 10inch extra space after each print, please let me know how to remove it.

following is working code taken from this git:

private void printPhotoFromExternal(final Bitmap bitmap) {
        new Thread(new Runnable() {
            public void run() {
                try {
                    getAndSaveSettings();

                    Looper.prepare();
                    helper.showLoadingDialog("Sending image to printer");
                    Connection connection = getZebraPrinterConn();
                    connection.open();
                    ZebraPrinter printer = ZebraPrinterFactory.getInstance(connection);
//                    printer.reset();

                    if (((CheckBox) findViewById(R.id.checkBox)).isChecked()) {
                        printer.storeImage(printStoragePath.getText().toString(), new ZebraImageAndroid(bitmap), 550, 412);
                    } else {
                        ZebraImageAndroid myBitmap = new ZebraImageAndroid(bitmap);

//                        connection.write("! UTILITIES\r\nIN-MILLIMETERS\r\nSETFF 10 2\r\nPRINT\r\n".getBytes());
                        printer.printImage(myBitmap, 0,100,-1,-1,false);
//                        connection.write("! UTILITIES\r\nIN-MILLIMETERS\r\nSETFF 10 2\r\nPRINT\r\n".getBytes());
                    }
                    connection.close();

                    if (file != null) {
                        file.delete();
                        file = null;
                    }
                } catch (ConnectionException e) {
                    helper.showErrorDialogOnGuiThread(e.getMessage());
                } catch (ZebraPrinterLanguageUnknownException e) {
                    helper.showErrorDialogOnGuiThread(e.getMessage());
                } catch (ZebraIllegalArgumentException e) {
                    helper.showErrorDialogOnGuiThread(e.getMessage());
                } finally {
                    bitmap.recycle();
                    helper.dismissLoadingDialog();
                    Looper.myLooper().quit();
                }
            }
        }).start();

    }

is anything wrong with code itself or it's printer fault?

Zulqurnain avatar Jul 23 '19 09:07 Zulqurnain

Does it feed the same length of blank space when printing something else? If yes, then most likely, it's related to the setting on the printer. Is the media type on the printer set to "journal" mode or "label" mode? The media type has to match to this setting. Then check the media feed length. ! U1 getvar "media.feed_length"<CR><LF>

ssizebra avatar Jul 23 '19 21:07 ssizebra

if it is journal can i do something about it programatically?

Zulqurnain avatar Jul 24 '19 16:07 Zulqurnain

If the printer is set in journal mode, the printer will treat the media as if it's continuous paper, like the receipt paper. You can set the continuous mode wiht the following command. ! U1 setvar "media.type" "journal"

If you use journal mode, then you also need to check the length setting is the desired length with the following commands. ! U1 getvar "zpl.label_length" ! U1 setvar "zpl.label_length" "200" // This sets the length to 200 dots.

You can do all the above programmatically.

ssizebra avatar Jul 24 '19 17:07 ssizebra

these commands are not working i wrote it like this connection.write("! U1\r\ngetvar\r\n\"media.feed_length\"".getBytes()); or like this connection.write("! U1\r\ngetvar\r\nmedia.feed_length".getBytes()); nothing works I'm using zebra zq320 printer

Zulqurnain avatar Jul 25 '19 09:07 Zulqurnain

Remove the "\r\n". connection.write("! U1 getvar "media.feed_length"".getBytes());

The command also works with Zebra Printer Setup Utilities for Windows.

ssizebra avatar Jul 25 '19 13:07 ssizebra

Nothing worked for me , so after some search , hit and trial i have found solution which i posted on SO https://stackoverflow.com/a/57202593/8399299

Zulqurnain avatar Jul 25 '19 23:07 Zulqurnain