TSPL Commands
TSPL (TSC Printer Language) is a label printer command language developed by TSC and widely used for label and barcode printing.
Overview
Section titled “Overview”Like CPCL, TSPL is a text-based command language. The main difference is that TSPL separates parameters with commas.
Syntax features
Section titled “Syntax features”| Feature | CPCL | TSPL |
|---|---|---|
| Parameter separators | Spaces | Commas |
| Strings | Double quotes | Double quotes |
| Units | dot | mm or dot |
Character encoding
Section titled “Character encoding”Page setup commands
Section titled “Page setup commands”Label dimensions (SIZE)
Section titled “Label dimensions (SIZE)”Set the label width and height.
SIZE width mm,height mmSIZE width mm,height mm,copies| Parameter | Description | Units |
|---|---|---|
| Width | Label width | mm |
| Height | Label height | mm |
| Copies | Number of copies (optional) | - |
Example:
SIZE 60 mm,40 mmSIZE 80 mm,50 mm,2Label gap (GAP)
Section titled “Label gap (GAP)”Set the gap between two labels.
GAP gap_height mm,offset mm| Parameter | Description | Units |
|---|---|---|
| Gap height | Label gap height | mm |
| Offset | Vertical offset | mm |
Example:
GAP 3 mm,0Black mark paper (BLINE)
Section titled “Black mark paper (BLINE)”Enable black mark paper mode.
BLINE height mm,offset mmContinuous paper (CONTINUOUS)
Section titled “Continuous paper (CONTINUOUS)”Enable continuous paper mode (without gaps).
CONTINUOUSLabel paper mode (LABEL)
Section titled “Label paper mode (LABEL)”Enable label paper printing mode.
LABELPrint direction (DIRECTION)
Section titled “Print direction (DIRECTION)”Set the print direction and mirroring.
DIRECTION direction,mirror| Parameter | Value | Description |
|---|---|---|
| Direction | 0 | Forward feed |
| Direction | 1 | Reverse feed |
| Mirror | 0 | No mirroring |
| Mirror | 1 | Mirrored printing |
Example:
DIRECTION 1,0Clear the buffer (CLS)
Section titled “Clear the buffer (CLS)”Clear the image buffer.
CLSPrint density (DENSITY)
Section titled “Print density (DENSITY)”Set the print density.
DENSITY density_value| Parameter | Range | Description |
|---|---|---|
| Density value | 0-15 | 0 = lightest, 15 = darkest |
Example:
DENSITY 8Print speed (SPEED)
Section titled “Print speed (SPEED)”Set the print speed.
SPEED speed_value| Parameter | Range | Description |
|---|---|---|
| Speed value | 1-6 | 3–4 recommended |
Example:
SPEED 4Coordinate offset (REFERENCE)
Section titled “Coordinate offset (REFERENCE)”Set the coordinate origin offset.
REFERENCE horizontal_offset,vertical_offsetExample:
REFERENCE 10,10Feed offset (OFFSET)
Section titled “Feed offset (OFFSET)”Set the paper feed offset.
OFFSET offset mmVertical offset (SHIFT)
Section titled “Vertical offset (SHIFT)”Set the vertical offset of the printed content.
SHIFT offsetText printing commands
Section titled “Text printing commands”Text (TEXT)
Section titled “Text (TEXT)”Print text content.
TEXT X,Y,"font",rotation,Xscale,Yscale,"content"TEXT X,Y,"font",rotation,Xscale,Yscale,alignment,"content"| Parameter | Description |
|---|---|
| X | Text starting X coordinate (dot) |
| Y | Text starting Y coordinate (dot) |
| Font | Font name |
| Rotation | Rotation angle (0/90/180/270) |
| X multiplier | Horizontal multiplier (1-8) |
| Y multiplier | Vertical multiplier (1-8) |
| Alignment | Alignment (optional) |
| Content | Text to print |
Available fonts
Section titled “Available fonts”| Font name | -dot matrix size | Description |
|---|---|---|
| TSS12.BF2 | 12 | 12-dot matrix font |
| TSS16.BF2 | 16 | 16-dot matrix font |
| TSS20.BF2 | 20 | 20-dot matrix font |
| TSS24.BF2 | 24 | 24-dot matrix font (recommended) |
| TSS28.BF2 | 28 | 28-dot matrix font |
| TSS32.BF2 | 32 | 32-dot matrix font |
| 1 | - | 8x12 Latin font |
| 2 | - | 12x20 Latin font |
| 3 | - | 16x24 Latin font |
| 4 | - | 24x32 Latin font |
| 5 | - | 32x48 Latin font |
Rotation angle
Section titled “Rotation angle”| Value | Angle |
|---|---|
| 0 | 0° |
| 90 | 90° |
| 180 | 180° |
| 270 | 270° |
Alignment
Section titled “Alignment”| Value | Description |
|---|---|
| 0 | Default (Left aligned) |
| 1 | Left aligned |
| 2 | Centered |
| 3 | Right aligned |
Example:
TEXT 50,50,"TSS24.BF2",0,1,1,"产品名称"TEXT 50,100,"TSS24.BF2",0,2,2,"放大两倍"TEXT 50,200,"3",0,1,1,"English Text"TEXT 50,250,"TSS24.BF2",0,1,1,2,"居中文本"Bold text
Section titled “Bold text”Append B1 after the font parameter to enable bold text.
TEXT X,Y,"font",rotation,Xscale,Yscale,B1,"content"Text box (BLOCK)
Section titled “Text box (BLOCK)”Print a paragraph with automatic line wrapping.
BLOCK X,Y,width,height,"font",rotation,Xscale,Yscale,"content"| Parameter | Description |
|---|---|
| Width | Text box width |
| Height | Text box height |
Example:
BLOCK 50,50,400,200,"TSS24.BF2",0,1,1,"这是一段很长的文本,会自动换行显示在文本框内。"Barcode printing commands
Section titled “Barcode printing commands”1D barcode (BARCODE)
Section titled “1D barcode (BARCODE)”Print a one-dimensional barcode.
BARCODE X,Y,"type",height,human_readable,rotation,narrow_bar,wide_bar,"content"| Parameter | Description |
|---|---|
| X | Barcode starting X coordinate |
| Y | Barcode starting Y coordinate |
| Type | Barcode type |
| Height | Barcode height (dot) |
| Human-readable | Show human-readable text (0=Hide, 1=Show) |
| Rotation | Rotation angle (0/90/180/270) |
| Narrow bar | Narrow bar width (1-10) |
| Wide bar | Wide bar width (narrow bar × ratio) |
| Content | Barcode data |
Supported barcode types
Section titled “Supported barcode types”| Type | Description |
|---|---|
| 128 | Code 128 (recommended) |
| 128M | Code 128 Subset |
| 39 | Code 39 |
| 93 | Code 93 |
| ITF | Interleaved 2 of 5 |
| UPCA | UPC-A |
| UPCE | UPC-E |
| EAN8 | EAN-8 |
| EAN13 | EAN-13 |
| CODABAR | Codabar |
| POST | Postnet |
| CPOST | China Post |
Example:
BARCODE 50,200,"128",80,1,0,2,4,"ABC123456"BARCODE 50,350,"EAN13",60,1,0,2,4,"6901234567890"QR code printing commands
Section titled “QR code printing commands”QR code (QRCODE)
Section titled “QR code (QRCODE)”Print a QR code.
QRCODE X,Y,error_correction_level,cell_width,mode,rotation,M2,S7,"content"| Parameter | Description |
|---|---|
| X | QR code starting X coordinate |
| Y | QR code starting Y coordinate |
| Error correction level | L/M/Q/H |
| Cell width | Cell width (1-10) |
| Mode | A=Automatic |
| Rotation | Rotation angle (0/90/180/270) |
Error correction level
Section titled “Error correction level”| Level | Error correction capacity |
|---|---|
| L | 7% |
| M | 15% |
| Q | 25% |
| H | 30% |
Example:
QRCODE 300,50,H,4,A,0,M2,S7,"https://example.com"QRCODE 50,50,M,6,A,0,"产品编号:12345"DataMatrix (DMATRIX)
Section titled “DataMatrix (DMATRIX)”Print a DataMatrix code.
DMATRIX X,Y,width,height,mode,"content"Example:
DMATRIX 50,50,400,400,x8,"DataMatrix Content"Graphics drawing commands
Section titled “Graphics drawing commands”Filled rectangle (BAR)
Section titled “Filled rectangle (BAR)”Draw a filled rectangle (horizontal or vertical lines only).
BAR X,Y,width,height| Parameter | Description |
|---|---|
| X | Top-left X coordinate |
| Y | Top-left Y coordinate |
| Width | Rectangle width |
| Height | Rectangle height |
Example:
BAR 30,100,420,2BAR 50,50,200,100Rectangular outline (BOX)
Section titled “Rectangular outline (BOX)”Draw a rectangular outline.
BOX X,Y,X_end,Y_end,line_widthBOX X,Y,X_end,Y_end,line_width,rounded_corners| Parameter | Description |
|---|---|
| X | Top-left X coordinate |
| Y | Top-left Y coordinate |
| X_end | Bottom-right X coordinate |
| Y_end | Bottom-right Y coordinate |
| Line width | Border line width |
| Rounded corners | Corner radius (optional) |
Example:
BOX 20,20,500,400,2BOX 50,50,300,200,3,10Diagonal line (DIAGONAL)
Section titled “Diagonal line (DIAGONAL)”Draw a diagonal line.
DIAGONAL X,Y,X_end,Y_end,line_widthDraw a line (LINE)
Section titled “Draw a line (LINE)”Draw a straight line, including diagonal lines.
LINE X,Y,X_end,Y_end,line_widthExample:
LINE 50,50,300,200,2Draw a circle (CIRCLE)
Section titled “Draw a circle (CIRCLE)”Draw a circle.
CIRCLE X,Y,diameter,line_width| Parameter | Description |
|---|---|
| X | Center X coordinate |
| Y | Center Y coordinate |
| Diameter | Circle diameter |
| Line width | Border line width |
Example:
CIRCLE 200,200,100,2Ellipse (ELLIPSE)
Section titled “Ellipse (ELLIPSE)”Draw an ellipse.
ELLIPSE X,Y,width,height,line_widthExample:
ELLIPSE 200,200,150,80,2Invert (REVERSE)
Section titled “Invert (REVERSE)”Invert the specified area.
REVERSE X,Y,width,heightExample:
REVERSE 50,50,200,100Image printing commands
Section titled “Image printing commands”Bitmap image (BITMAP)
Section titled “Bitmap image (BITMAP)”Print a bitmap image.
BITMAP X,Y,width,height,mode,dataDownload a bitmap to the printer
Section titled “Download a bitmap to the printer”DOWNLOAD "filename",data_size,dataPrint a downloaded bitmap (PUTBMP)
Section titled “Print a downloaded bitmap (PUTBMP)”PUTBMP X,Y,"filename"Query commands
Section titled “Query commands”Query printer status
Section titled “Query printer status”<ESC>!?Query serial number (SN)
Section titled “Query serial number (SN)”~!TQuery battery level
Section titled “Query battery level”~!BQuery firmware version
Section titled “Query firmware version”~!FQuery printer model
Section titled “Query printer model”~!IGet shutdown timeout
Section titled “Get shutdown timeout”~!@Get ribbon status
Section titled “Get ribbon status”~!CConfiguration commands
Section titled “Configuration commands”Set shutdown timeout
Section titled “Set shutdown timeout”Set the automatic shutdown timeout.
SET AUTOOFF time| Parameter | Description |
|---|---|
| Time | Shutdown timeout (minutes), 0 disables automatic shutdown |
Ribbon mode (RIBBON)
Section titled “Ribbon mode (RIBBON)”Set thermal transfer or direct thermal mode.
SET RIBBON ONSET RIBBON OFF| Set | Description |
|---|---|
| ON | Thermal transfer mode (uses ribbon) |
| OFF | Direct thermal mode |
Tear-off mode (TEAR)
Section titled “Tear-off mode (TEAR)”Set tear-off mode.
SET TEAR ONSET TEAR OFFPeel-off mode (PEEL)
Section titled “Peel-off mode (PEEL)”Set peel-off mode.
SET PEEL ONSET PEEL OFFCutter mode (CUTTER)
Section titled “Cutter mode (CUTTER)”Set cutter mode.
SET CUTTER ONSET CUTTER OFFEncoding configuration
Section titled “Encoding configuration”Set the printer’s character encoding.
CODEPAGE GBKCODEPAGE UTF-8Learn paper (DETECT)
Section titled “Learn paper (DETECT)”Automatically detect the paper type and label gaps.
DETECTPrint control commands
Section titled “Print control commands”Print (PRINT)
Section titled “Print (PRINT)”Execute the print job.
PRINT copies,labels_per_copyPRINT copies| Parameter | Description |
|---|---|
| Copies | Number of copies |
| Labels per copy | Number of labels per copy (optional, default 1) |
Example:
PRINT 1PRINT 3,2Print a self-test page (SELFTEST)
Section titled “Print a self-test page (SELFTEST)”Print the printer’s self-test page.
SELFTESTComplete examples
Section titled “Complete examples”Product label
Section titled “Product label”SIZE 60 mm,40 mmGAP 3 mm,0DIRECTION 1,0DENSITY 8SPEED 4CLS
TEXT 180,30,"TSS24.BF2",0,2,2,"商品标签"BAR 30,80,420,2TEXT 30,100,"TSS24.BF2",0,1,1,"品名: 有机苹果"TEXT 30,140,"TSS24.BF2",0,1,1,"规格: 500g/袋"TEXT 30,180,"TSS24.BF2",0,1,1,"产地: 山东烟台"TEXT 30,220,"TSS24.BF2",0,1,1,B1,"价格: ¥25.90"BARCODE 80,270,"128",60,1,0,2,4,"6901234567890"QRCODE 380,100,M,4,A,0,"https://example.com/product"
PRINT 1Shipping label
Section titled “Shipping label”SIZE 100 mm,150 mmGAP 3 mm,0DIRECTION 1,0CLS
BOX 20,20,780,1180,3TEXT 300,40,"TSS24.BF2",0,2,2,"快递单"BAR 20,100,760,3
TEXT 40,130,"TSS24.BF2",0,1,1,"寄件人: 张三"TEXT 40,170,"TSS24.BF2",0,1,1,"电话: 138****1234"TEXT 40,210,"TSS24.BF2",0,1,1,"地址: 上海市浦东新区张江高科"BAR 20,260,760,2
TEXT 40,290,"TSS24.BF2",0,1,1,"收件人: 李四"TEXT 40,330,"TSS24.BF2",0,1,1,"电话: 139****5678"BLOCK 40,370,700,120,"TSS24.BF2",0,1,1,"地址: 北京市朝阳区望京SOHO T3 25层"BAR 20,500,760,3
BARCODE 150,550,"128",100,1,0,3,6,"SF1234567890123"TEXT 280,680,"TSS24.BF2",0,1,1,"SF1234567890123"
QRCODE 300,750,H,8,A,0,"SF1234567890123"
TEXT 280,1000,"TSS24.BF2",0,1,1,"扫码查询物流"
PRINT 1Asset label (with rounded border)
Section titled “Asset label (with rounded border)”SIZE 70 mm,30 mmGAP 2 mm,0DIRECTION 1,0DENSITY 10CLS
BOX 10,10,550,230,2,15TEXT 30,30,"TSS24.BF2",0,1,1,"资产编号:"TEXT 180,30,"TSS24.BF2",0,1,1,B1,"IT-2024-001234"BAR 30,70,500,1TEXT 30,90,"TSS24.BF2",0,1,1,"设备名称: MacBook Pro"TEXT 30,130,"TSS24.BF2",0,1,1,"使用部门: 技术研发部"QRCODE 420,80,M,3,A,0,"IT-2024-001234"
PRINT 1SDK integration
Section titled “SDK integration”To use TSPL commands in an application, see the SDK guide for your language:
- Dart SDK - Cross-platform Flutter development
- Java SDK - Native Android development
- JavaScript SDK - Mini Program development
- OpenHarmony SDK - HarmonyOS / OpenHarmony applications
- Objective-C SDK - Native iOS development
- Swift SDK - iOS/macOS development