Professional Documents
Culture Documents
POS Printer SDK
POS Printer SDK
1.Introduction.............................................................................................................................................................3
3.Function reference...................................................................................................................................................4
public static void POS_Open(string sPortName, int nComBaudrate, int nComDataBits, int nComStopBits,
public static void POS_S_TextOut(string pszString, int nOrgx, int nWidthTimes, int nHeightTimes, int
public static void POS_S_SetBarcode(string pszInfoBuffer, int nOrgx, int nType, int nWidthX, int nHeight,
public static void POS_PL_SetArea(int nOrgx, int nOrgy, int nWidth, int nHeight, int nDirection)............18
1
public static void POS_PL_TextOut(string pszString, int nOrgx, int nOrgy, int nWidthTimes, int
public static void POS_PL_SetBarcode(string pszInfoBuffer, int nOrgx, int nOrgy, int nType, int nWidthX,
4. Appendix ………………………………………………………………………………………………………..24
2
1.Introduction
SerialPosLib.dll is a C# dynamic depot based on vs2005, to conveniently directly control the printer by
1.General function
This function supports printer’s 3 types printing modes simultaneously (standard mode, page mode, label
mode).
3
3. Function of supporting page mode printing (P) or label mode printing (L).
Version: 2.0.1
Remark:
3. Function reference
Public static void POS_Open(string sPortName, int nComBaudrate, int nComDataBits, int nComStopBits,
Description:
nComDataBits 5,6,7,8
nParam 0 indicates flow control off, “0x1” indicates DTR/RTS flow control 控 on.
Remarks:
4
Whether the ports on/off should be distinguished by POS_IsOpen(). If fail to open the ports, pleaese refer to
“lasterror” to find out reasons. Only few functions request to set “lasterror”.
This function can be for open Ethernet port and USB port as well, but only one of these two work at a time.
Which port to work depending on “nParam”, if “nParam” says “0 or 1”,then “sPortName” means serial
port, example “com1 , com2” etc. If “nParam” says “2”, then “sPortName” means Ethernet port,
example “192.168.0.67” etc. If “nParam” says “3” ,then means printing to driver port, example “RP80
Printer” etc.
Description:
Description:
Description:
Parameter:
timeout millisecond.
Description:
Parameter:
timeout millisecond.
5
Public static void POS_Write(byte[] buffer)
Description:
If serial port already on, then data of buffer will be sent out to serial port.
Parameter:
Description:
If serial port opened /on, then data will be read from serial port to fill buffer, null to USB port.
Parameter:
Description:
Reset printer to clear the printing buffer data, and the on setting of character and line spacing. Then printing
Description:
Parameter:
nPrintMode
6
POS_PRINT_MODE_STANDARD 0x00 Standard mode (Line
mode)
mode
Description:
Parameter:
nHorizontalMU
[in] set horizonal motion unit to be 25.4 / nHorizontalMU millimeter, 0~255 available.
nVerticalMU
[in] set vertical motion unit to be 25.4 / nVerticalMU millimeter, 0~255 available.
Description:
Parameter:
nCharSet
[in] designates character sets. Different character sets have different definitions for ASCII value of
“0x23~0x7E”.
7
Value Meaning
0x00 U.S.A
0x01 France
0x02 Germany
0x03 U.K.
0x04 Denmark I
0x05 Sweden
0x06 Italy
0x07 Spain I
0x08 Japan
0x09 Nonway
0x0A Denmark II
0x0B Spain II
0x0D Korea
nCodePage
[in] designates character’s codepage. Different codepages have different definition for ASCII value of
Description:
Paper forward.
Description:
8
Set character’s line spacing.
Parameter:
nDistance
Description:
Parameter:
nDistance
To be confirmed.
Description:
Cut paper.
Parameter:
9
nMode
nDistance
Remarks:
1.If designated to be full cut mode, then ignore the parameter “nDistance”.
2.If designated to be semi cut mode, then paper slips “nDistance” dots to cut.
Description:
Parameter:
Remarks:
Please try not to insert this command into command array with 2 or more bytes.
Printer will do this command immediately when it receives, even though it is doing printing.
Printer will return when gets this command, whatever status it stays.
10
n=1 correspond buffer[0]
n=2correspond buffer[1]
11
Public static void POS_S_SetAreaWidth(int nWidth)
Description:
12
Parameter:
nWidth
0~65535 dots available, but printing width should not exceed 576 limited to the paper width.
Public static void POS_S_TextOut(string pszString, int nOrgx, int nWidthTimes, int nHeightTimes, int
Description:
Transfer the character string needed to be printed to buffer area, and given an absolute starting position in X
direction (horizon), designates enlarge percentage, types and style for every character in the width and
height.
Parameter:
pszString
nOrgx
[in] Designates the starting position dot from the left edge.
0~65535 available.
nWidthTimes
0~7 available.
nHeightTimes
0~7 available.
13
nFontType
nFontStyle
Public static void POS_S_SetBarcode(string pszInfoBuffer, int nOrgx, int nType, int nWidthX, int nHeight,
Description:
14
Parameter:
pszInfoBuffer
[in] Label character string. The allowed area and format concerns to the specific label.
nOrgx
[in] Designates the label starting position dot from the left edge.
0~65535 available.
nType
nWidthX
nHeight
nHriFontType
[in] Designates the font type for character HRI (Human Readable Interpretation).
nHriFontPosition
[in] Designates the position for character HRI (Human Readable Interpretation).
Description:
16
Print bitmap
Parameter:
Remarks:
Bitmap is .Net format. This function will enlarge Bitmap to be times of min. 8 pixel, for example, enlarge
575 to be 576,383 or enlarge to be 384, then transfer it to be solid color, then transfer to the commands to printer,
Public static void POS_PL_SetArea(int nOrgx, int nOrgy, int nWidth, int nHeight, int nDirection)
Description:
Parameter:
nOrgx
[in] Designates given area’s starting position dot in X direction (horizon) from the left edge.
0~ 65535 available.
nOrgy
[in] Designates given area’s starting position dot in Y direction (vertical) from the top edge (current
0~65535 available.
nWidth
0~65535。
nHeight
0~65535。
17
nDirection
OP
Public static void POS_PL_TextOut(string pszString, int nOrgx, int nOrgy, int nWidthTimes, int
Description:
Transfer the character string needed to be printed to buffer area, and given an absolute starting position in X
direction (horizon), designates enlarge percentage, types and style for every character in the width and
height.
Parameter:
pszString
18
nOrgx
[in] Designates the starting position dot in X direction (horizon) from the left edge.
0~ 65535 available.
nOrgy
[in] Designates the starting position dot in Y direction (vertical) from the top edge.
0~65535 available.
nWidthTimes
0~7 available.
nHeightTimes
0~7 available.
nFontType
nFontStyle
19
POS_FONT_STYLE_NORMAL 0x00 Normal
Public static void POS_PL_SetBarcode(string pszInfoBuffer, int nOrgx, int nOrgy, int nType, int nWidthX,
Description:
Parameter:
pszInfoBuffer
[in] The character string needed to be printed. The allowed area and format concerns to the specific label
type.
nOrgx
[in] Designates the label starting position dot from the left edge.
0~65535 available.
nOrgy
[in] Designates the label starting position dot from the top edge.
0~65535 available.
nType
20
Flag Value Meaning
POS_BARCODE_TYPE_CODE93 0x48 25
nWidthX
nHeight
1~255 available.
nHriFontType
[in] Designates the font type for character HRI (Human Readable Interpretation).
21
Flag Value Meaning
nHriFontPosition
[in] Designates the character position for HRI (Human Readable Interpretation).
below label
Description:
Remarks:
1.If function works, paper in to print content, but the buffer data of page or label will be reserved. This
Description:
22
Clear the buffer data of printing page and label content.
4. Appendix
Generally, printer works under standard mode and page mode only.
Under standard mode, as long as the printer receives line printing or paper-in command, it will do as
command.
For example, when refer to function “POS_S_TextOut” and send character“ABCDEF”, printer will do the
character string accord with function then store in buffer area, waiting for printing. When refer to function
“POS_FeedLine”, paper feeds and the character string will be printed out. However, if the length exceeds the
length of received buffering area, printer will feed paper and print automatically.
Under page mode, printer will store all the received processed data to page buffer area without printing.
For example, when refer to function “POS_PL_TextOut” and send character string “ABCDEF”, printer will
do the character string accord with function then store in buffer area, waiting for printing, if further refers to
function “POS_FeedLine”, printer will locate the printing position to the next line head. If refers to function “
POS_PL_Print”, printer will feed paper and print out the data stored in buffer.
Under these two printing modes, data in buffer area will not be cleared automatically. If under page mode,
In addition, there is another printing mode call “label mode”, it includes black mark label mode and white
mark label mode. Label mode’s printing principle can be refer to page mode.
23
A.2 Setting printing area
1 . Printing area is set by function “POS_PL_SetArea”. If paper feeding and printing commands are finished
before referring this function, printer will print content at left side (x0,y0). Width of rectangle printing area (dx
dot) expands at Dx (vertical at paper in) to right side; Height expand down at Y direction (paper in direction). If
no refer to this function to set printing area, then printing area will be defaulted.
2. After the printer’s printing area and printing area direction are set up by POS_PL_S etArea), its character,
bitmap or down-left label in the printing area will be served as base point.
The downloaded bitmap in printing data and label data take the current location as its down-left, aligning
with baseline.
3.Before receiving a command including paper-in, if the printing data is already over the printing area
(containing character spacing), then printer will auto paper-in forward 1 line (the length paper-in depends on the
line-height set by POS_SetLineSpacing) and printing position locates to next line head.
4. The default line-height is 1/6 inch, if the vertical resolution is 203DPI, then approximately to be 34 dots. If
the printing characters overlap with the last lines’, caused by: next line containing enlarged characters over 2
times in vertical, or bitmap occupies 2 lines even more, label is higher than normal character and the amount of
printer’s paper feeding cannot meet, then by adding line-height will avoid this matter.
UPC-A 11 ≤ n ≤ 12 48 ≤ d ≤ 57
UPC-E 11 ≤ n ≤ 12 48 ≤ d ≤ 57
JAN13 (EAN13) 12 ≤n ≤ 13 48 ≤ d ≤ 57
JAN 8 (EAN8) 7 ≤n ≤ 8 48 ≤ d ≤ 57
24
36, 37,43
d1 = dk = 42
ITF 1 ≤ n≤ 255 48 ≤ d ≤ 57
43,45,46,47 58
128 code enciphers 128 ASCII characters and 100 numbers from 00 to 99, even some special characters
SHIFT character
“SHIFT” enable to change barcode code in the first character A to B, or from B to A, it also can back to
“SHIFT”character only can exchange between character A and B, it cannot function the current code
These characters can exchange the back code character to characters A, B and C.
The usage for these functional characters depends on the applied software. In characters C, only FNC1 can
be used.
25
B.2.1 128-code character sets
Character sets A
NULL 00 0 ( 28 40 P 50 80
SOH 01 1 ) 29 41 Q 51 81
STX 02 2 * 2A 42 R 52 82
ETX 03 3 + 2B 43 S 53 83
EOT 04 4 , 2C 44 T 54 84
ENQ 05 5 - 2D 45 U 55 85
ACK 06 6 . 2E 46 V 56 86
BEL 07 7 / 2F 47 W 57 87
BS 08 8 0 30 48 X 58 88
HT 09 9 1 31 49 Y 59 89
LF 0A 10 2 32 50 Z 5A 90
VT 0B 11 3 33 51 [ 5B 91
FF 0C 12 4 34 52 \ 5C 92
CR 0D 13 5 35 53 ] 5D 93
SO 0E 14 6 36 54 ^ 5E 94
SI 0F 15 7 37 55 _ 5F 95
ETB 17 23 ? 3F 63
CAN 18 24 @ 40 64
EM 19 25 A 41 65
SUB 1A 26 B 42 66
ESC 1B 27 C 43 67
26
FS 1C 28 D 44 68
GS 1D 29 E 45 69
RS 1E 30 F 46 70
US 1F 31 G 47 71
SP 20 32 H 48 72
! 21 33 I 49 73
" 22 34 J 4A 74
# 23 35 K 4B 75
$ 24 36 L 4C 76
% 25 37 M 4D 77
& 26 38 N 4E 78
' 27 39 O 4F 79
27
Character sets B
SP 20 32 H 48 72 p 70 112
! 21 33 I 49 73 q 71 113
" 22 34 J 4A 74 r 72 114
# 23 35 K 4B 75 s 73 115
$ 24 36 L 4C 76 t 74 116
% 25 37 M 4D 77 u 75 117
& 26 38 N 4E 78 v 76 118
' 27 39 O 4F 79 w 77 119
( 28 40 P 50 80 x 78 120
) 29 41 Q 51 81 y 79 121
* 2A 42 R 52 82 z 7A 122
+ 2B 43 S 53 83 { 7B,7B 123,123
, 2C 44 T 54 84 | 7C 124
- 2D 45 U 55 85 } 7D 125
. 2E 46 V 56 86 — 7E 126
/ 2F 47 W 57 87 DEL 7F 127
7 37 55 _ 5F 95
8 38 56 ` 60 96
9 39 57 a 61 97
28
: 3A 58 b 62 98
; 3B 59 c 63 99
< 3C 60 d 64 100
= 3D 61 e 65 101
> 3E 62 f 66 102
? 3F 63 g 67 103
@ 40 64 h 68 104
A 41 65 i 69 105
B 42 66 j 6A 106
C 43 67 k 6B 107
D 44 68 l 6C 108
E 45 69 m 6D 109
F 46 70 n 6E 110
G 47 71 o 6F 111
Character sets C
0 00 0 40 28 40 80 50 80
1 01 1 41 29 41 81 51 81
2 02 2 42 2A 42 82 52 82
3 03 3 43 2B 43 83 53 83
4 04 4 44 2C 44 84 54 84
5 05 5 45 2D 45 85 55 85
6 06 6 46 2E 46 86 56 86
7 07 7 47 2F 47 87 57 87
8 08 8 48 30 48 88 58 88
9 09 9 49 31 49 89 59 89
10 0A 10 50 32 50 90 5A 90
11 0B 11 51 33 51 91 5B 91
12 0C 12 52 34 52 92 5C 92
13 0D 13 53 35 53 93 5D 93
29
14 0E 14 54 36 54 94 5E 94
15 0F 15 55 37 55 95 5F 95
16 10 16 56 38 56 96 60 96
17 11 17 57 39 57 97 61 97
18 12 18 58 3A 58 98 62 98
19 13 19 59 3B 59 99 63 99
23 17 23 63 3F 63
24 18 24 64 40 64
25 19 25 65 41 65
26 1A 26 66 42 66
27 1B 27 67 43 67
28 1C 28 68 44 68
29 1D 29 69 45 69
30 1E 30 70 46 70
31 1F 31 71 47 71
32 20 32 72 48 72
33 21 33 73 49 73
34 22 34 74 4A 74
35 23 35 75 4B 75
36 24 36 76 4C 76
37 25 37 77 4D 77
38 26 38 78 4E 78
39 27 39 79 4F 79
To print data via USB port, the driver should be pre-installed in the printer, says RP58 or RP80 driver. Then
the first parameter set to be printer itself name, the last parameter to be “3”, when invoke “open”. After open
invoked, please use “”IsOpen” to ensure it works, and confirm the printer’s name correct, if it cannot work.
30
Moreover, “lasterror” can be used to find out the error (Choose to use “USB00x” in printer property dialog).
Opening the printer’s port by driver, only “write” available, and “read, timeout” will be ignored.
PS. If a printer commits printing by driver, all the data will be sent to driver by SDK. The designated port
will be set by driver. (It means, the printer supports parallel interface and USB port etc.)
31