forked from ansontio/EscPosEncoder
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.d.ts
239 lines (217 loc) · 8.39 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
export default class EscPosEncoder {
/**
* Initialize the printer
*
* @return {object} Return the object, for easy chaining commands
*
*/
initialize(): EscPosEncoder;
/**
* Change the code page
*
* @param {string} codepage The codepage that we set the printer to
* @return {object} Return the object, for easy chaining commands
*
*/
codepage(codepage: string): EscPosEncoder;
/**
* Print text
*
* @param {string} value Text that needs to be printed
* @param {number} wrap Wrap text after this many positions
* @return {object} Return the object, for easy chaining commands
*
*/
text(value: string, wrap?: number): EscPosEncoder;
/**
* Print a newline
*
* @return {object} Return the object, for easy chaining commands
*
*/
newline(): EscPosEncoder;
/**
* Print text, followed by a newline
*
* @param {string} value Text that needs to be printed
* @param {number} wrap Wrap text after this many positions
* @return {object} Return the object, for easy chaining commands
*
*/
line(value: string, wrap?: number): EscPosEncoder;
/**
* Underline text
*
* @param {boolean|number} value true to turn on underline, false to turn off, or 2 for double underline
* @return {object} Return the object, for easy chaining commands
*
*/
underline(value?: boolean | number): EscPosEncoder;
/**
* Italic text
*
* @param {boolean} value true to turn on italic, false to turn off
* @return {object} Return the object, for easy chaining commands
*
*/
italic(value?: boolean): EscPosEncoder;
/**
* Bold text
*
* @param {boolean} value true to turn on bold, false to turn off
* @return {object} Return the object, for easy chaining commands
*
*/
bold(value?: boolean): EscPosEncoder;
/**
* Change width of text
*
* @param {number} width The width of the text, 1 - 8
* @return {object} Return the object, for easy chaining commands
*
*/
width(width: number): EscPosEncoder;
/**
* Change height of text
*
* @param {number} height The height of the text, 1 - 8
* @return {object} Return the object, for easy chaining commands
*
*/
height(height: number): EscPosEncoder;
/**
* Invert text
*
* @param {boolean} value true to turn on white text on black, false to turn off
* @return {object} Return the object, for easy chaining commands
*
*/
invert(value: boolean): EscPosEncoder;
/**
* Change text size
*
* @param {string} value small or normal
* @return {object} Return the object, for easy chaining commands
*
*/
size(value: string): EscPosEncoder;
/**
* Change text alignment
*
* @param {string} value left, center or right
* @return {object} Return the object, for easy chaining commands
*
*/
align(value: string): EscPosEncoder;
/**
* Insert a table
*
* @param {array} columns The column definitions
* @param {array} data Array containing rows. Each row is an array containing cells.
* Each cell can be a string value, or a callback function.
* The first parameter of the callback is the encoder object on
* which the function can call its methods.
* @return {object} Return the object, for easy chaining commands
*
*/
table(columns: any[], data: any[]): EscPosEncoder;
/**
* Insert a horizontal rule
*
* @param {object} options And object with the following properties:
* - style: The style of the line, either single or double
* - width: The width of the line, by default the width of the paper
* @return {object} Return the object, for easy chaining commands
*
*/
rule(options: Object): EscPosEncoder;
/**
* Insert a horizontal rule
*
* @param {object} options And object with the following properties:
* - style: The style of the border, either single or double
* - width: The width of the box, by default the width of the paper, if specified
* - marginLeft: Space between the left border and the left side of the paper
* - marginRight: Space between the right border and the right side of the paper
* - paddingLeft: Space between the contents and the left border of the box
* - paddingRight: Space between the contents and the right border of the box
* @param {string|function} contents A string value, or a callback function.
* The first parameter of the callback is the encoder object on
* which the function can call its methods.
* @return {object} Return the object, for easy chaining commands
*
*/
box(options: Object, contents: string | Function): EscPosEncoder;
/**
* Barcode
*
* @param {string} value the value of the barcode
* @param {string} symbology the type of the barcode
* @param {number} height height of the barcode
* @return {object} Return the object, for easy chaining commands
*
*/
barcode(value: string, symbology: string, height: number): EscPosEncoder;
/**
* QR code
*
* @param {string} value the value of the qr code
* @param {number} model model of the qrcode, either 1 or 2
* @param {number} size size of the qrcode, a value between 1 and 8
* @param {string} errorlevel the amount of error correction used, either 'l', 'm', 'q', 'h'
* @return {object} Return the object, for easy chaining commands
*
*/
qrcode(value: string, model?: number, size?: number, errorlevel?: string): EscPosEncoder;
/**
* Image
*
* @param {object} element an element, like a canvas or image that needs to be printed
* @param {number} width width of the image on the printer
* @param {number} height height of the image on the printer
* @param {string} algorithm the dithering algorithm for making the image black and white
* @param {number} threshold threshold for the dithering algorithm
* @return {object} Return the object, for easy chaining commands
*
*/
image(
element: Object,
width: number,
height: number,
algorithm: string,
threshold: number
): EscPosEncoder;
/**
* Cut paper
*
* @param {string} value full or partial. When not specified a full cut will be assumed
* @return {object} Return the object, for easy chaining commands
*
*/
cut(value?: string): EscPosEncoder;
/**
* Pulse
*
* @param {number} device 0 or 1 for on which pin the device is connected, default of 0
* @param {number} on Time the pulse is on in milliseconds, default of 100
* @param {number} off Time the pulse is off in milliseconds, default of 500
* @return {object} Return the object, for easy chaining commands
*
*/
pulse(device?: number, on?: number, off?: number): EscPosEncoder;
/**
* Add raw printer commands
*
* @param {array} data raw bytes to be included
* @return {object} Return the object, for easy chaining commands
*
*/
raw(data: any[]): EscPosEncoder;
/**
* Encode all previous commands
*
* @return {Uint8Array} Return the encoded bytes
*
*/
encode(): Uint8Array;
}