Question

Realizing that I should be using Line Print mode (as opposed to label mode) for sending CPCL to the Zebra QL 220 belt printer, I'm in the process of refactoring my working code (Why does everything print on the same line, even though I'm adding crlfs?) to this:

serialPort.Write("! 0 200 200 210 1\r\n"); 

serialPort.Write(string.Format("! U1 setvar {0} {1}", "device.languages", "line_print"));
serialPort.Write("Hallo die Welt\r\n\r\n"); //Bonjour le Monde --- Hola el Mundo --- Hallo die Welt

serialPort.Write("BARCODE-TEXT 7 0 5\r\n"); 
serialPort.Write(string.Format("BARCODE 128 1 1 50 150 130 {0}\r\n\r\n", barcode));
serialPort.Write("POSTFEED 120\r\n"); // empirical observation shows 120 is about the right amount of extra tape to expel after printing
serialPort.Write("PRINT\r\n");

This prints the barcode and its human-readable number beneath it (the value in "barcode"),but the text "Hallo die Welt" is not printed. Why not? Do I need a call to Print after each line, or...???

UPDATE

It still prints the barcode only (not "Hallo die Welt") with this code:

serialPort.Write("! 0 200 200 210 1\r\n");
serialPort.Write("! U1 SETLP 7 0 24\r\n"); 
serialPort.Write("Hallo die Welt\r\n\r\n"); 
serialPort.Write("BARCODE-TEXT 7 0 5\r\n"); 
serialPort.Write(string.Format("BARCODE 128 1 1 50 150 130 {0}\r\n\r\n", barcode));
serialPort.Write("POSTFEED 120\r\n");
serialPort.Write("PRINT\r\n");

UPDATE 2

This works (label mode):

serialPort.Write("! 0 200 200 210 1\r\n");
serialPort.Write("TEXT 4 0 30 40 Hallo die Welt\r\n\r\n"); //Bonjour le Monde --- Hola el Mundo --- Hallo die Welt
serialPort.Write("BARCODE-TEXT 7 0 5\r\n"); 
serialPort.Write(string.Format("BARCODE 128 1 1 50 150 130 {0}\r\n\r\n", barcode));
serialPort.Write("POSTFEED 120\r\n"); 
serialPort.Write("PRINT\r\n");

It prints:

~~~~~~~~~~~~~~~~~~~~~~~
Hallo die Welt

<barcode as a barcode>
<barcode as a number>
~~~~~~~~~~~~~~~~~~~~~~~

...but this doesn't work (line print mode):

serialPort.Write(string.Format("! U1 setvar {0} {1}", "device.languages", "line_print"));
serialPort.Write("! U1 SETLP 7 0 24\r\n");
serialPort.Write("Hallo die Welt\r\n\r\n");
serialPort.Write("! U1 BARCODE-TEXT 7 0 5\r\n");
serialPort.Write(string.Format("! U1 BARCODE 128 1 1 50 150 130 {0}\r\n\r\n", barcode));
serialPort.Write("! U1 SETLP 5 2 46"); 
serialPort.Write(barcode);
serialPort.Write("! U1 PRINT\r\n");

The problem is, I need to use Line Print mode.

Was it helpful?

Solution

You also need a \r\n after every SGD command (your setvar in this case)

It should be

! U1 setvar "device.languages" "line_print"\r\n

You also need to put the double quotes around the 2 parameters of the SETVAR command.

UPDATE:

oh, btw, just because the printer is in line_print mode, doesn't mean that it doesn't understand CPCL code. So the code above in your example is CPCL code, not just line print. If you put TEXT in front, it should work

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top