Reputation: 128
I am printing receipts from an android device to a zebra imz 220, part of the receipt contains a pin which has a larger text size for readability but this section does not print correctly, half of the text is missing:
when I print the pin section of the receipt I set the label length and print out the required fields by sending the following commands:
zebraPrinter.sendCommand("! U1 setvar \"zpl.label_length\" \"50\"\n\r");
zebraPrinter.sendCommand( "^XA^" +
"FO0,0^FB384,1,0,C,0^ADI,18,10^FDData^FS^" +
"XZ");
zebraPrinter.sendCommand( "^XA^" +
"FO0,0^FB384,1,0,C,0^ADI,18,10^FD.............................^FS^" +
"XZ");
zebraPrinter.sendCommand( "^XA^" +
"FO0,0^FB384,1,0,C,0^ADI,18,10^FDData Token:^FS^" +
"XZ");
zebraPrinter.sendCommand( "^XA^" +
"FO0,0^FB384,1,0,C,0^ADI,18,10^FD(123,R123.23)^FS^" +
"XZ");
zebraPrinter.sendCommand( "^XA^" +
"FO0,0^FB384,2,0,C,0^ADI,36,20^FD"+pin+"^FS^" +
"XZ");
zebraPrinter.sendCommand( "^XA^" +
"FO0,0^FB384,1,0,C,0^ADI,18,10^FD123 @ 0.11c "+"^FS^" +
"XZ");
zebraPrinter.sendCommand( "^XA^" +
"FO0,0^FB384,1,0,C,0^ADI,18,10^FD..............................^FS^" +
"XZ");
if I change the label length from 50 to 75 then the entire pin field is visible but the spacing of this section becomes undesirable:
How can I keep the spacing of the pin section when its length is set to 50 without obscuring the pin field ?
Any pointers in the right direction will be greatly appreciated!
Upvotes: 1
Views: 1655
Reputation: 2800
It looks like you are using ZPL. It might be better to create one label instead of sending a new label for each line of your receipt. You can surround your entire label with a single ^XA and ^XZ. See below. This has the advantage of letting you set the position for each line of text by hand, and thus increasing the line height for the 'pin' line. Also, you only open communication to your printer once, so it should perform (marginally) faster. Example:
StringBuilder zplString = new StringBuilder();
zplString.append("^XA");
zplString.append("FO0,0^FB384,1,0,C,0^ADI,18,10^FDData^FS^"");
zplString.append("FO0,50^FB384,1,0,C,0^ADI,18,10^FD.............................^FS^");
zplString.append("FO0,100^FB384,1,0,C,0^ADI,18,10^FDData Token:^FS^");
zplString.append("FO0,150^FB384,1,0,C,0^ADI,18,10^FD(123,R123.23)^FS^");
zplString.append("FO0,200^FB384,2,0,C,0^ADI,36,20^FD"+pin+"^FS^");
// Notice we set starting position (FO) to 0,300. This gives our previous line (the pin line) more room.
zplString.append("FO0,300^FB384,1,0,C,0^ADI,18,10^FD123 @ 0.11c "+"^FS^");
zplString.append("FO0,350^FB384,1,0,C,0^ADI,18,10^FD..............................^FS^");
zplString.append("^XZ");
// only send the command once since it includes the entire label
zebraPrinter.sendCommand(zplString.toString());
Notice: if you take this approach, you have to calculate the starting X,Y position for each line of text. This means you will have to change each beginning FO0,0 to something like FO00, FO0,50, FO0,100, etc. The second parameter of each FO command is the starting 'Y' position for that line. So, you can simply increment the line AFTER the line with the pin to something higher so that the text does not overlap.
Upvotes: 1