Skip to content

CPCL Commands

CPCL (Comtec Printer Control Language) is a text-based command language for portable label printers.

CPCL uses human-readable text. Each command consists of a command name and parameters separated by spaces.

Command name Parameters 1 Parameters 2 Parameters 3 ...
  • Enclose strings in double quotes "
  • Escape double quotes inside text as ["]
TEXT 4 0 100 100 "Hello World"
TEXT 4 0 100 150 "Say ["]Hello["]"

Create a print page and set its dimensions and number of copies.

! offset horizontal_resolution vertical_resolution label_height number_of_copies
ParameterDescriptionUnits
OffsetPage offsetdot
Horizontal resolutionPrinthead horizontal resolutionDPI
Vertical resolutionPrinthead vertical resolutionDPI
Label heightLabel heightdot
Number of copiesNumber of copies-

Example:

! 0 200 200 400 1

Set the page width.

PAGE-WIDTH width
ParameterDescriptionUnits
WidthPage widthdot

Example:

PAGE-WIDTH 576

Set the printer’s positioning mode.

FORM
  • FORM - Advance to the next label (can be called after PRINT)
  • FEED - Position at the label (must be called before PRINT)

Print text content.

TEXT font size X Y "content"
T font size X Y "content"
ParameterDescription
FontFont ID
SizeFont size
XText starting X coordinate (dot)
YText starting Y coordinate (dot)
ContentText to print
Font enumFont IDSize-dot matrix height
TSS1655016
TSS206020
TSS2424024
TSS287028
TSS324032

Example:

TEXT 24 0 50 50 "产品名称"
TEXT 7 0 50 100 "规格型号"
T 4 0 50 150 "大号文字"

Print text at a rotation angle.

T90 font size X Y "content"
T180 font size X Y "content"
T270 font size X Y "content"
CommandRotation angle
T0° (default)
T9090°
T180180°
T270270°

Set the text scaling multipliers.

SETMAG horizontal_multiplier vertical_multiplier
ParameterDescriptionRange
Horizontal multiplierHorizontal multiplier1-8
Vertical multiplierVertical multiplier1-8

Example:

SETMAG 2 2
TEXT 24 0 50 50 "放大两倍的文字"
SETMAG 1 1

Set text boldness.

SETBOLD switch
ParameterDescription
1Enable bold
0Disable bold

Example:

SETBOLD 1
TEXT 24 0 50 50 "加粗文字"
SETBOLD 0

Set text underlining.

UNDERLINE switch
ParameterDescription
ONEnable underline
OFFDisable underline

Example:

UNDERLINE ON
TEXT 24 0 50 50 "带下划线的文字"
UNDERLINE OFF

Set text alignment.

CENTER
LEFT
RIGHT

Example:

CENTER
TEXT 24 0 0 50 "居中文本"
LEFT
TEXT 24 0 30 100 "左对齐文本"
RIGHT
TEXT 24 0 0 150 "右对齐文本"

Print reverse text.

INVERSE-LINE X Y width height
ParameterDescription
XReverse area starting X coordinate
YReverse area starting Y coordinate
WidthReverse area width
HeightReverse area height

Print a one-dimensional barcode.

BARCODE type narrow_bar_width wide_to_narrow_ratio height X Y "content"
ParameterDescription
TypeBarcode type
Narrow bar widthNarrow bar width
Wide-to-narrow ratioWide-to-narrow bar ratio
HeightBarcode height (dot)
XBarcode starting X coordinate
YBarcode starting Y coordinate
ContentBarcode data
TypeDescriptionDefault narrow bar width
128Code 1282
39Code 392
93Code 931
CODABARCodabar2
EAN8EAN-82
EAN13EAN-132
UPCAUPC-A2
UPCEUPC-E2
I2OF5Interleaved 2 of 52

Example:

BARCODE 128 1 2 50 50 200 "1234567890"
BARCODE EAN13 1 2 60 50 300 "6901234567890"

Print a rotated barcode.

VBARCODE type narrow_bar_width wide_to_narrow_ratio height X Y "content"
BARCODE90 type narrow_bar_width wide_to_narrow_ratio height X Y "content"
BARCODE180 type narrow_bar_width wide_to_narrow_ratio height X Y "content"
BARCODE270 type narrow_bar_width wide_to_narrow_ratio height X Y "content"
CommandRotation angle
BARCODE0° (default)
VBARCODE90°
BARCODE9090°
BARCODE180180°
BARCODE270270°

Print a QR code.

SETQRVER error_correction_level_value
rotation_angle
QR X Y M 2 U width
error_correction_levelA,content
ENDQR
ParameterDescription
Error correction level valueL=1, M=2, Q=3, H=4
Rotation angle0/90/180/270
XQR code starting X coordinate
YQR code starting Y coordinate
WidthCell width (2-20)
Error correction levelL/M/Q/H
ContentQR code data
LevelNumeric valueError correction capacity
L17%
M215%
Q325%
H430%

Example:

SETQRVER 2
0
QR 50 100 M 2 U 6
MA,https://example.com
ENDQR

Draw a straight line, including diagonal lines.

LINE X1 Y1 X2 Y2 width
ParameterDescription
X1Start point X coordinate
Y1Start point Y coordinate
X2End point X coordinate
Y2End point Y coordinate
WidthLine width

Example:

LINE 30 100 546 100 2
LINE 30 100 200 300 1

Draw a rectangular outline.

BOX X1 Y1 X2 Y2 width
ParameterDescription
X1Top-left X coordinate
Y1Top-left Y coordinate
X2Bottom-right X coordinate
Y2Bottom-right Y coordinate
WidthBorder line width

Example:

BOX 30 50 546 350 2

Print a bitmap image.

EG width_in_bytes height X Y image_data
CG width_in_bytes height X Y image_data
ParameterDescription
Width in bytesImage width/8
HeightImage height (dot)
XImage starting X coordinate
YImage starting Y coordinate
Image dataHexadecimal image data

Print a watermark image.


{S}
{SN}
{M}
{V}
{B}

Execute the print job. Every CPCL job must end with a PRINT command.

PRINT

! 0 200 200 400 1
PAGE-WIDTH 576
CENTER
SETMAG 2 2
TEXT 24 0 0 30 "商品标签"
SETMAG 1 1
LEFT
LINE 30 80 546 80 2
TEXT 24 0 30 100 "名称: 有机苹果"
TEXT 24 0 30 140 "规格: 500g/袋"
TEXT 24 0 30 180 "产地: 山东烟台"
SETBOLD 1
TEXT 24 0 30 220 "价格: ¥25.90"
SETBOLD 0
BARCODE 128 1 2 50 100 280 "6901234567890"
SETQRVER 2
0
QR 400 100 M 2 U 5
MA,https://example.com/product/123
ENDQR
PRINT
! 0 200 200 800 1
PAGE-WIDTH 576
BOX 20 20 556 780 2
CENTER
SETMAG 2 2
TEXT 24 0 0 40 "快递单"
SETMAG 1 1
LINE 20 90 556 90 2
LEFT
TEXT 24 0 40 110 "寄件人: 张三"
TEXT 24 0 40 150 "电话: 138****1234"
TEXT 24 0 40 190 "地址: 上海市浦东新区"
LINE 20 230 556 230 1
TEXT 24 0 40 250 "收件人: 李四"
TEXT 24 0 40 290 "电话: 139****5678"
TEXT 24 0 40 330 "地址: 北京市朝阳区xxx路xxx号"
LINE 20 380 556 380 2
CENTER
BARCODE 128 2 2 80 0 420 "SF1234567890123"
TEXT 7 0 0 520 "SF1234567890123"
SETQRVER 2
0
QR 200 580 M 2 U 8
MA,SF1234567890123
ENDQR
PRINT

To integrate CPCL commands in an application, see the SDK guide for your language:

Complete CPCL command reference (PDF)