Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zebra Printer ZQ320 is printing Extra space after print #4

Open
Zulqurnain opened this issue Jul 23, 2019 · 6 comments
Open

Zebra Printer ZQ320 is printing Extra space after print #4

Zulqurnain opened this issue Jul 23, 2019 · 6 comments

Comments

@Zulqurnain
Copy link

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?

@ssizebra
Copy link
Collaborator

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"

@Zulqurnain
Copy link
Author

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

@ssizebra
Copy link
Collaborator

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.

@Zulqurnain
Copy link
Author

Zulqurnain commented Jul 25, 2019

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

@ssizebra
Copy link
Collaborator

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

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

@Zulqurnain
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants