TSPL Windows SDK Manual
TSPL Windows SDK Manual
1
[TSPL Windows SDK] ......................................................................................................................... 1
1. Information of the Manual .................................................................................................. 3
2. Operation System .................................................................................................................3
3. Remark .................................................................................................................................. 3
4. Method ................................................................................................................................. 3
4.1. InitPrinter ...................................................................................................................3
4.2. ReleasePrinter ............................................................................................................3
4.3. OpenPort ....................................................................................................................4
4.4. ClosePort ....................................................................................................................5
4.5. WriteData ...................................................................................................................5
4.6. ReadData ....................................................................................................................6
4.7. TSPL SelfTest ............................................................................................................. 6
4.8. TSPL_Bar .................................................................................................................... 7
4.9. TSPL_BarCode ............................................................................................................ 7
4.10. TSPL_BitMap ............................................................................................................ 9
4.11. TSPL_Image ............................................................................................................10
4.12. TSPL_Setup ............................................................................................................ 11
4.13. TSPL_ClearBuffer ................................................................................................... 12
4.14. TSPL_Box ................................................................................................................12
4.15. TSPL_QrCode ......................................................................................................... 13
4.16. TSPL_Text ...............................................................................................................14
4.17. TSPL_Print .............................................................................................................. 15
4.18. TSPL_FormFeed ..................................................................................................... 16
4.19. TSPL_SetTear ......................................................................................................... 16
4.20. TSPL_SetRibbon ..................................................................................................... 17
4.21. TSPL_Offset ............................................................................................................18
4.22. TSPL_Direction ....................................................................................................... 18
4.23. TSPL_Feed .............................................................................................................. 19
4.24. TSPL_Home ............................................................................................................ 19
4.25. TSPL_Learn .............................................................................................................20
4.26. TSPL_GetSN ............................................................................................................20
4.27. TSPL_GetPrinterStatus ...........................................................................................21
4.28. TSPL_SetCodePage ................................................................................................ 21
4.29. TSPL_PDF417 ......................................................................................................... 22
4.30. TSPL_Block ............................................................................................................. 24
4.31. TSPL_Reverse ......................................................................................................... 25
4.32. TSPL_GapDetect .................................................................................................... 26
4.33. TSPL_Dmatrix .........................................................................................................26
4.34. TSPL_SetCutter ...................................................................................................... 27
2
1. Information of the Manual
This SDK manual provides the dll file information for Windows application development.
We continuously promote and update the function and quality of all our products. Any change
to the product specification and the manual will be without any further notice.
2. Operation System
Windows 10 or above
3. Remark
When error code Return Value is greater than 0, it is the internal error of Windows system,
please refer to related help file.
The printer resolution is 200 dpi,1 mm=8 dot;The printer resolution is 300 dpi,1 mm=12 dot.
4. Method
4.1.InitPrinter
Set up the target printer of specified model (the printer object must be created before any
printer operation).
void* InitPrinter (
const TCHAR* model
);
Parameter:
const TCHAR* model
[in] Specify the model of target printer.
Return Value:
success:Returns a handle to the printer object
fail:Return NULL
4.2.ReleasePrinter
The method is to release the resources of the printer object (the created printer object must be
released after the operation is completed ).
int ReleasePrinter (
3
void* hPrinter
);
Parameter:
void* hPrinter
[in] Handle to the target printer object that needs to be released
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
4.3.OpenPort
Open the communication port and connect with the printer. After successfully connected,
other functions can be used. If failed connecting, please check the error information. Currently it
supports USB, internet, serial interface.
int OpenPort (
void* hPrinter,
const TCHAR* setting
);
Parameter:
void* hPrinter
[in] The created target printer object.
const TCHAR* setting
[in] Set the communication port parameters to connect to the target printer. See the table
below for details:
Configuration List:
Type Configuration Description Sample
4
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_USB_DEVICE_NOT_FOUND -17 Failed, device not found
ERROR_IO_OPEN_FAILED -8 Failed to open port
4.4.ClosePort
This function is to close the communication port and disconnect with the printer.
int ClosePort (
void* hPrinter
);
Parameter:
void* hPrinter
[in] The created target printer object.
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -3 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -2 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
4.5.WriteData
int WriteData(
void* handle,
unsigned char* buffer,
unsigned int size
);
Parameter:
void* handle
[in] The created target printer object.
unsigned char* buffer
[in] The data sent to the printer ( hex string) .
unsigned int size
[in] The length of the sent data.
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
5
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
4.6.ReadData
int ReadData(
void* handle,
unsigned char* buffer,
unsigned int size
);
Parameter:
void* handle
[in] The created target printer object.
unsigned char* buffer
[in] Printer data to be read.
unsigned int size
[in] The length of the data to be read.
Return Value:
Code Value Description
>0 >0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_OPEN_FAILED -8 Failed to open port
4.7.TSPL SelfTest
This method is to print a self-test page for the printer, which contains
basic configuration information for the printer.
int TSPL_SelfTest(
void* hPrinter
);
Parameter:
void* hPrinter
[in] The created target printer object.
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
6
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.8.TSPL_Bar
int TSPL_Bar(
void* hPrinter,
int x,
int y,
int width,
int height
);
Parameter:
void* hPrinter
[in] The created target printer objec
int x
[in] horizontal starting position, unit: dot
int y
[in] vertical starting position,unit: dot
int width
[in] width,unit: dot
int height
[in] height,unit: dot
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.9.TSPL_BarCode
int TSPL_BarCode(
void* hPrinter,
int x,
int y,
BarcodeType type,
const char* content,
7
int height,
TextAlign showText = TextAlign::HIDE,
Rotation rotation = Rotation::ROTATION_0,
int narrow = 2,
int wide = 2
);
Parameter:
void* hPrinter
[in] The created target printer object.
int x
[in] Horizontal starting position, unit:dot.
int y
[in] Vertical starting position,unit:dot.
BarcodeType type
[in] barcode type.
Barcode type Value
Code 128 CODE_128
Code 128M CODE_128M
EAN 128 EAN_128
Interleaved 2 of 5 CODE_25
Interleaved 2 of 5 with check digits CODE_25C
Code 39 CODE_39
Code 39C CODE_39C
Code 93 CODE_93
EAN 13 EAN_13
EAN 13 with 2 digits add-on EAN_13_2
EAN 13 with 5 digits add-on EAN_13_5
EAN 8 EAN_8
EAN 8 with 2 digits add-on EAN_8_2
EAN 8 with 5 digits add-on EAN_8_5
Codabar CODA
Postnet POST
UPC-A UPCA
UPC-A with 2 digits add-on UPCA_2
UPC-A with 5 digits add-on UPCA_5
UPC- E UPCE
UPC- E with 2 digits add-on UPCE_2
UPC- E with 5 digits add-on UPCE_5
China post code CPOST
MSI code MSI
MSI with check digit MSIC
PLESSEY code PLESSEY
ITF 14 code ITF_14
EAN 14 code EAN_14
Code 11 EAN_14
TELEPEN TELEPEN
TELEPENN TELEPENN
PLANET PLANE
CODE_49 CODE_49
DPI DPI
8
DPL DPL
const char* content
[in] barcode data.
int height
[in] height, unit:dot.
TextAlign showText
[in] text display type
Text display type Value
do not display text HIDE
text is displayed on the left LEFT
text centered CENTER
text is displayed on the right RIGHT
Rotation rotation
[in] barcode rotation direction
Rotation direction Value
No rotation ROTATION_0
Rotate 90 degrees ROTATION_90
Rotate 180 degrees ROTATION_180
Rotate 270 degrees ROTATION_270
int narrow
[in] Narrow Bar Width, unit:dot.
int wide
[in] Wide Bar Width, unit:dot.
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.10. TSPL_BitMap
int TSPL_BitMap(
void* hPrinter,
int x,
int y,
int width,
int height,
int mode,
unsigned char * data
);
Parameter:
void* hPrinter
[in] The created target printer object.
int x
9
[in] Horizontal starting position, unit:dot.
int y
[in] Vertical starting position,unit:dot.
int width
[in] Image width, unit:byte.
int height
[in] Bitmap height, unit:dot.
int mode
[in] Mode for printing bitmap.
mode Value
OVERWRITE 0
OR 1
XOR 2
unsigned char * data
[in] Binarized bitmap data
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.11. TSPL_Image
This method is for printing the specified image (supports bmp, jpg, gif, etc), this function is
suitable for printing LOGO.
Convert the image of the specified path to bitmap data and send it to the printer and print.
int TSPL_Image(
void* hPrinter,
int x,
int y,
int mode,
const char* imgPath
);
Parameter:
void* hPrinter
[in] The created target printer object.
int x
[in] Horizontal starting position, unit:dot.
int y
[in] Vertical starting position,unit:dot.
int mode
[in] Mode for printing Image.
mode Value
OVERWRITE 0
10
OR 1
XOR 2
const char* imgPath
[in] The correct path to the image.
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.12. TSPL_Setup
int TSPL_Setup(
void* hPrinter,
int printSpeed,
int printDensity,
int labelWidth,
int labelHeight,
int labelType,
int gapHeight,
int offset
);
Parameter:
void* hPrinter
[in] The created target printer object.
int printSpeed
[in] printing speed.
int printDensity
[in] print density (range: 0- 15).
int labelWidth
[in] Label width, unit:mm.
int labelHeight
[in] Label length, unit:mm.
int labelType
[in] label paper type (0: black mark/continuous paper 1: seam label/continuous paper).
int gapHeight
[in] The space between two labels, if it is set to 0, it means that it is continuous
paper,unit:mm.
int offset
[in] offset position,unit:mm.
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
11
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.13. TSPL_ClearBuffer
This function is to clear the printer memory cache. Clear the printer cache before executing print
data.
int TSPL_ClearBuffer(
void* hPrinter
);
Parameter:
void* hPrinter
[in] The created target printer object.
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.14. TSPL_Box
int TSPL_Box(
void* hPrinter,
int x,
int y,
int x_end,
int y_end,
int thickness = 1,
int radius = 0
);
Parameter:
void* hPrinter
[in] The created target printer object.
int x
[in] Horizontal starting position, unit:dot.
12
int y
[in] Vertical starting position,unit:dot.
int x_end
[in] Horizontal end position, unit:dot.
int y_end
[in] Vertical end position, unit:dot.
int thickness
[in] Line thickness., unit:dot.
int radius
[in] Specifies whether to have rounded corners, unit:dot.,default is 0.
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.15. TSPL_QrCode
TSPL_QrCode(
void* hPrinter,
int x,
int y,
int width,
int eccLevel,
int mode,
int rotate,
int model,
int mask,
const char* data
);
Parameter:
void* hPrinter
[in] The created target printer object.
int x
[in] Horizontal starting position, unit:dot.
int y
[in] Vertical starting position,unit:dot.
int eccLevel
[in] Error correction level.
Error correction Value
level
7% 0
15% 1
25% 2
13
30% 3
int width
[in] QR code print width (range: 1- 10).
int mode
[in] Automatic / manual coding (A : automatic, 1 : manual).
int rotate
[in] QR code rotation angle.
Rotation direction Value
No rotation ROTATION_0
Rotate 90 degrees ROTATION_90
Rotate 180 degrees ROTATION_180
Rotate 270 degrees ROTATION_270
int model
[in] QR code version (0 : Basic, 1 : Enhanced).
int mask
[in] mask(range: 0-8 ).
const char* data
[in] QR code data.
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.16. TSPL_Text
int TSPL_Text(
void* hPrinter,
int x,
int y,
const char* fontName,
const char* content,
int rotation = 0,
int x_multiplication = 1,
int y_multiplication = 1,
int alignment = 0
);
Parameter:
void* hPrinter
[in] The created target printer object.
int x
[in] Horizontal starting position, unit:dot.
int y
14
[in] Vertical starting position,unit:dot.
const char* fontName
[in] Font name.
Font name Value
normal “0”
8x12 “1”
12x20 “2”
16x24 “3”
24x32 “4”
32x48 “5”
14x19 “6”
21x27 “7”
14x25 “8”
Simplified Chinese “TSS24.BF2”
const char* content
[in] text content.
int rotation
[in] Rotation angle.
Rotation direction Value
No rotation 0
Rotate 90 degrees 1
Rotate 180 degrees 2
Rotate 270 degrees 3
int x_multiplication
[in] Horizontal magnification ratio, effective parameters: 1~10.int y_multiplication
[in] Vertical magnification ratio, effective parameters: 1~10.
int alignment
[in] the alignment of the text.
Alignment Value
Default (Left) 0
Left 1
Center 2
Right 3
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.17. TSPL_Print
int TSPL_Print(
15
void* hPrinter,
int num,
int copies
);
Parameter:
void* hPrinter
[in] The created target printer object.
int num
[in] The number of labels.
int copies
[in] Print the number of copies of each label.
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.18. TSPL_FormFeed
The method is to push the paper to the starting position of the next label.
int TSPL_FormFeed(
void* hPrinter
);
Parameter:
void* hPrinter
[in] The created target printer object.
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.19. TSPL_SetTear
This function is to enable/ disable the tear- off function for setting the printer.
16
int TSPL_SetTear(
void* hPrinter,
int mode
);
Parameter:
void* hPrinter
[in] The created target printer object.
int mode
[in] Enable/disable the tear-off function (0 : OFF, 1 : ON).
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.20. TSPL_SetRibbon
Parameter:
void* hPrinter
[in] The created target printer object.
int mode
[in] Ribbon mode; 0=turn off the ribbon function; 1=start the ribbon function; 2=inner
winding ribbon; 3=outer winding ribbon.
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
17
4.21. TSPL_Offset
This method is used to define the extra feed length of each label of the printer.
int TSPL_Offset(
void* hPrinter,
int distance
)
Parameter:
void* hPrinter
[in] The created target printer object.
int distance
[in] Extra feed length, unit:dot.
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.22. TSPL_Direction
int TSPL_Direction(
void* hPrinter,
Direction direction,
int mirror
);
Parameter:
void* hPrinter
[in] The created target printer object.
Direction direction
[in] Define the print orientation of the printer(DIRECTION_FORWARD:Forward
printing,DIRECTION_REVERSE:reverse print).
int mirror
[in]
Define the mirror of the printed content, 0-normal; 1-mirror
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
18
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.23. TSPL_Feed
int TSPL_Feed(
void* hPrinter,
int n
);
Parameter:
void* hPrinter
[in] The created target printer object.
int n
[in] Feed length Valid parameter: ±1~9999,When the number is negative, the paper will be
ejected backward, unit:dot.
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.24. TSPL_Home
This method is used to feed the paper to the starting position for the printer.
int TSPL_Home(
void* hPrinter
);
Parameter:
void* hPrinter
[in] The created target printer object.
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
19
Other values Other values the error code returned by the
Windows system
4.25. TSPL_Learn
int TSPL_Learn(
void* hPrinter
)
Parameter:
void* hPrinter
[in] The created target printer object.
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.26. TSPL_GetSN
This method is used to obtain the serial number of the printer SN.
int TSPL_GetSN(
void* hPrinter,
char* snBuffer,
int bufSize
);
Parameter:
void* hPrinter
[in] The created target printer object.
char* snBuffer
[in/out]The buffer address used to get the serial number.
int bufSize
[in]buffer size.
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
20
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.27. TSPL_GetPrinterStatus
int TSPL_GetPrinterStatus(
void* hPrinter,
unsigned int* printerStatus
)
Parameter:
void* hPrinter
[in]The created target printer object.
int * printerStatus
[in,out]
Current status of the printer.
status value
Normal 0
The print head is opened 1
Paper jam 2
Out of paper 4
Out of ribbon 8
Print pause 16
Printing 32
Cover opened 64
Other error 128
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_READ_FAILED -11 Failed to read data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.28. TSPL_SetCodePage
This method is used to set the code page for the printer.
int TSPL_SetCodePage(
void* hPrinter,
21
const char* codepage
);
Parameter:
void* hPrinter
[in] The created target printer object.
const char* codepage
[in]code page.
7-bit code page 8-bit code page Windows code page ISO code page
US USA 437 United States 1250 Central Europe 8859- 1 Latin 1
A
BRI British 737 Greek 1251 Cyrillic 8859-2 Latin 2
GE German 850 Multilingual 1252 Latin I 8859-3 Latin 3
R
FRE French 851 Greek1 1253 Greek 8859-4 Batltic
DA Danish 852 Slavic 1254 Turkish 8859-5 Cyrillic
N
ITA Italian 855 Cyrillic 1255 Hebrew 8859-6 Arabic
SPA Spansh 857 Turkish 1256 Arabic 8859-7 Greek
SW Sweidsh 860 Portuguese 1257 Batltic 8859-8 Hebrew
E
SWI Swiss 861 Icelandic 1258 Vietnam 8859-9 Turkish
862 Hebrew 932 Japanese shift-JIS 8859- 10 Latin 6
863 Canadian/Fren ch 936 simplified 8859- 15 Latin 9
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.29. TSPL_PDF417
int TSPL_PDF417(
void* hPrinter,
int x,
22
int y,
int width,
int height,
int rotate,
const char* option,
const char* data
);
Parameter:
void * hPrinter
[in] The created target printer object.
int x
[in] Horizontal starting position, unit:dot.
int y
[in] Vertical starting position,unit:dot.
int width
[in] QR code width, unit:dot.
int height
[in] QR code height, unit:dot.
int rotate
[in] Rotation angle.
Rotation direction Value
No rotation 0
Rotate 90 degrees 1
Rotate 180 degrees 2
Rotate 270 degrees 3
const char* option
[in]Options (Example: E3,W2,H8).
P Data compression method:
0 : automatic
1 : binary mode
E Error check level (0~8)
M Bar code center print mode
0 : This mode will print in the upper left
corner alignment area 1 : will print in the
middle area
Ux,y,z Code readable
x: the x coordinate specified by the readable
character
y: the y coordinate specified by the readable
character
c: maximum number of readable characters per line
W Module width (2~9: dot)
H Height of small bar code (4~99: dot)
R Maximum number of rows
C Maximum number of columns
T Whether to cut off
0 : No
1 : Yes
Lm Indicates the length (1~2048)
const char* data
23
[in] QR code data.
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.30. TSPL_Block
int TSPL_Block(
void* hPrinter,
int x,
int y,
int width,
int height,
const char* fontName,
const char* content,
Rotation rotation = ROTATION_0,
int x_multiplication = 1,
int y_multiplication = 1,
int alignment = 0
);
Parameter:
void* hPrinter
[in] The created target printer object.
int x
[in] Horizontal starting position, unit:dot.
int y
[in] Vertical starting position,unit:dot.
int width
[in] The width of block for the paragraph in dots.
int height
[in] The height of block for the paragraph in dots
const char* fontName
[in] Font name.
Font name value
normal “0”
8x12 “1”
12x20 “2”
16x24 “3”
24x32 “4”
32x48 “5”
14x19 “6”
24
21x27 “7”
14x25 “8”
简体中文 “TSS24.BF2”
const char* content
[in] Data in block. The maximum data length is 4092 bytes.
Rotation rotation
[in] The rotation angle of text.
Rotation direction Value
No rotation ROTATION_0
Rotate 90 degrees ROTATION_90
Rotate 180 degrees ROTATION_180
Rotate 270 degrees ROTATION_270
int x_multiplication
[in] Horizontal multiplication, up to 10x, Available factors: 1~10.
int y_multiplication
[in] Vertical multiplication, up to 10x,Available factors: 1~10.
int alginment
[in] Text alignment.
Alignment Value
Default (Left) 0
Left 1
Center 2
Right 3
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.31. TSPL_Reverse
int TSPL_Reverse(
void* hPrinter,
int x,
int y,
int width,
int height
);
Parameter:
void* hPrinter
[in] The created target printer object.
int x
25
[in] Horizontal starting position, unit:dot.
int y
[in] Vertical starting position,unit:dot.
int width
[in] width, unit:dot.
int heigh
[in] height, unit:dot.
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.32. TSPL_GapDetect
Parameter:
void* hPrinter
[in] The created target printer object.
int x
[in] Paper length (in dots).
int y
[in] Gap length (in dots)
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.33. TSPL_Dmatrix
int TSPL_Dmatrix(
void* hPrinter,
int x,
26
int y,
int width,
int height,
const char* content,
int blockSize = 0,
int row = 10,
int col = 10
);
Parameter:
void* hPrinter
[in] The created target printer object.
int x
[in] Horizontal starting position, unit:dot.
int y
[in] Vertical starting position,unit:dot.
int width
[in] The expected width of barcode area (in dots)
int height
[in] The expected height of barcode area (in dots)
const char* content
[in] Content of DataMatrix 2D bar code.
int blockSize
[in] optional,Module size (in dots).
int row
[in] optional,Symbol size of row: 10 to 144.
int col
[in] optional,Symbol size of col: 10 to 144.
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
4.34. TSPL_SetCutter
int TSPL_SetCutter(
void* hPrinter,
int pieces
);
Parameter:
void* hPrinter
[in] The created target printer object.
int copies
[in] Set number of printing labels per cut.0=Turn off the cutter function,-1=
Cut paper after printing job, 1-65535=Number of labels for cut paper
27
Return Value:
Code Value Description
ERROR_CM_SUCCESS 0 success
ERROR_CM_INVALID_HANDLE -2 failed with invalid handle
ERROR_CM_INVALID_PARAMETER -1 Invalid argument
ERROR_CM_INSUFFICIENT_MEMORY -4 failed, out of memory
ERROR_IO_WRITE_FAILED -9 Failed to send data
ERROR_IO_WRITE_TIMEOUT -10 Write data timed out
Other values Other values the error code returned by the
Windows system
28