CPCL Programming Language for Zebra Mobile Printers
This language is a little harder to master than ZPL code, but once you get the basic concepts it gets easier.
Here is a sample of C# code that sends CPCL code to the serial port:
if (sPrinterLanguage == “CPCL”)
{
oLabelPrintScreen.serialPort1.WriteLine(“! 0 200 200 580 ” + qty + Constants.CRLF);
oLabelPrintScreen.serialPort1.WriteLine(“! UTILITIES” + Constants.CRLF);
oLabelPrintScreen.serialPort1.WriteLine(“GAP-SENSE” + Constants.CRLF);
oLabelPrintScreen.serialPort1.WriteLine(“SET-TOF 0” + Constants.CRLF);
oLabelPrintScreen.serialPort1.WriteLine(“IN-MILLIMETERS” + Constants.CRLF);
oLabelPrintScreen.serialPort1.WriteLine(“BARCODE 128 .4 2 10 6 0 ” + oLabelPrintScreen.txtItem.Text.Trim() + Constants.CRLF);
oLabelPrintScreen.serialPort1.WriteLine(“TEXT 4 1 6 12 ” + oLabelPrintScreen.txtItem.Text.Trim() + Constants.CRLF);
oLabelPrintScreen.serialPort1.WriteLine(“TEXT 4 1 6 23 ” + d1.ToUpper() + Constants.CRLF);
oLabelPrintScreen.serialPort1.WriteLine(“TEXT 4 1 6 34 ” + d2.ToUpper() + Constants.CRLF);
oLabelPrintScreen.serialPort1.WriteLine(“TEXT 4 1 6 45 ” + oLabelPrintScreen.txtSerial.Text.Trim() + Constants.CRLF);
oLabelPrintScreen.serialPort1.WriteLine(“BARCODE 128 .4 2 10 6 58 ” + oLabelPrintScreen.txtSerial.Text.Trim() + Constants.CRLF);
if (oLabelPrintScreen.cbDate.Checked) oLabelPrintScreen.serialPort1.WriteLine(“TEXT 4 1 55 45 ” + “Received: ” + dtnow + Constants.CRLF);
oLabelPrintScreen.serialPort1.WriteLine(“FORM” + Constants.CRLF);
oLabelPrintScreen.serialPort1.WriteLine(“PRINT” + Constants.CRLF);
}
where:
qty is a variable with the number of labels to print
txtItem is the Item Number
d1 and d2 are the Item Description text split into two halves
txtSerial is another text field
dtnow is the date stamp of when the label was printed. The resulting label looks like: