tauri-plugin-thermal-printer 1.1.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +401 -54
- package/dist-js/index.cjs +263 -3
- package/dist-js/index.d.ts +222 -18
- package/dist-js/index.js +234 -4
- package/package.json +2 -2
package/dist-js/index.cjs
CHANGED
|
@@ -2,20 +2,280 @@
|
|
|
2
2
|
|
|
3
3
|
var core = require('@tauri-apps/api/core');
|
|
4
4
|
|
|
5
|
+
const PAPER_SIZE_CHARS_PER_LINE = {
|
|
6
|
+
Mm40: 21,
|
|
7
|
+
Mm44: 24,
|
|
8
|
+
Mm58: 32,
|
|
9
|
+
Mm72: 42,
|
|
10
|
+
Mm80: 48,
|
|
11
|
+
Mm104: 62,
|
|
12
|
+
};
|
|
13
|
+
const PAPER_SIZE_PIXELS_WIDTH = {
|
|
14
|
+
Mm40: 256,
|
|
15
|
+
Mm44: 288,
|
|
16
|
+
Mm58: 384,
|
|
17
|
+
Mm72: 512,
|
|
18
|
+
Mm80: 576,
|
|
19
|
+
Mm104: 752,
|
|
20
|
+
};
|
|
21
|
+
const DEFAULT_PAPER_SIZE = 'Mm80';
|
|
22
|
+
function getPaperSizeCharsPerLine(paperSize) {
|
|
23
|
+
return PAPER_SIZE_CHARS_PER_LINE[paperSize];
|
|
24
|
+
}
|
|
25
|
+
function getPaperSizePixelsWidth(paperSize) {
|
|
26
|
+
return PAPER_SIZE_PIXELS_WIDTH[paperSize];
|
|
27
|
+
}
|
|
28
|
+
// ─── Convenience style presets ────────────────────────────────────────────────
|
|
29
|
+
const TEXT_ALIGN = {
|
|
30
|
+
LEFT: 'left',
|
|
31
|
+
CENTER: 'center',
|
|
32
|
+
RIGHT: 'right',
|
|
33
|
+
};
|
|
34
|
+
const TEXT_SIZE = {
|
|
35
|
+
NORMAL: 'normal',
|
|
36
|
+
HEIGHT: 'height',
|
|
37
|
+
WIDTH: 'width',
|
|
38
|
+
DOUBLE: 'double',
|
|
39
|
+
};
|
|
40
|
+
const TEXT_FONT = {
|
|
41
|
+
A: 'A',
|
|
42
|
+
B: 'B',
|
|
43
|
+
C: 'C',
|
|
44
|
+
};
|
|
45
|
+
const BARCODE_TYPE = {
|
|
46
|
+
UPC_A: 'UPC-A',
|
|
47
|
+
UPC_E: 'UPC-E',
|
|
48
|
+
EAN13: 'EAN13',
|
|
49
|
+
EAN8: 'EAN8',
|
|
50
|
+
CODE39: 'CODE39',
|
|
51
|
+
ITF: 'ITF',
|
|
52
|
+
CODABAR: 'CODABAR',
|
|
53
|
+
CODE93: 'CODE93',
|
|
54
|
+
CODE128: 'CODE128',
|
|
55
|
+
};
|
|
56
|
+
const BARCODE_TEXT_POSITION = {
|
|
57
|
+
NONE: 'none',
|
|
58
|
+
ABOVE: 'above',
|
|
59
|
+
BELOW: 'below',
|
|
60
|
+
BOTH: 'both',
|
|
61
|
+
};
|
|
62
|
+
const QR_ERROR_CORRECTION = {
|
|
63
|
+
/** Low — 7% recovery */
|
|
64
|
+
L: 'L',
|
|
65
|
+
/** Medium — 15% recovery (recommended default) */
|
|
66
|
+
M: 'M',
|
|
67
|
+
/** Quartile — 25% recovery */
|
|
68
|
+
Q: 'Q',
|
|
69
|
+
/** High — 30% recovery */
|
|
70
|
+
H: 'H',
|
|
71
|
+
};
|
|
72
|
+
const IMAGE_MODE = {
|
|
73
|
+
NORMAL: 'normal',
|
|
74
|
+
DOUBLE_WIDTH: 'double_width',
|
|
75
|
+
DOUBLE_HEIGHT: 'double_height',
|
|
76
|
+
QUADRUPLE: 'quadruple',
|
|
77
|
+
};
|
|
78
|
+
const CUT_MODE = {
|
|
79
|
+
FULL: 'full',
|
|
80
|
+
PARTIAL: 'partial',
|
|
81
|
+
};
|
|
82
|
+
const CODE_PAGE = {
|
|
83
|
+
/** CP437 — ASCII only, no accented characters */
|
|
84
|
+
DEFAULT: 'Default',
|
|
85
|
+
/** CP850 — Spanish, French, Italian, German */
|
|
86
|
+
SPANISH: 'Spanish',
|
|
87
|
+
/** CP850 — Alias of Spanish */
|
|
88
|
+
FRENCH: 'French',
|
|
89
|
+
/** CP860 — Portuguese (ã, õ) */
|
|
90
|
+
PORTUGUESE: 'Portuguese',
|
|
91
|
+
/** CP863 — Canadian French */
|
|
92
|
+
CANADIAN_FRENCH: 'CanadianFrench',
|
|
93
|
+
/** CP865 — Nordic languages (å, ø, æ) */
|
|
94
|
+
NORDIC: 'Nordic',
|
|
95
|
+
/** CP1252 — Wide Western European, includes € */
|
|
96
|
+
WINDOWS_LATIN: 'WindowsLatin',
|
|
97
|
+
/** CP866 — Russian / Cyrillic */
|
|
98
|
+
RUSSIAN: 'Russian',
|
|
99
|
+
/** CP852 — Eastern Europe (Polish, Czech, Slovak, Hungarian) */
|
|
100
|
+
EASTERN_EUROPE: 'EasternEurope',
|
|
101
|
+
/** Strips accents and special chars to plain ASCII. Use when the printer
|
|
102
|
+
* ignores ESC t commands. á→a, é→e, ñ→n, ß→ss, ¿→?, €→EUR, etc. */
|
|
103
|
+
ACCENT_REMOVER: 'AccentRemover',
|
|
104
|
+
};
|
|
105
|
+
// ─── Helper builders ──────────────────────────────────────────────────────────
|
|
106
|
+
/** Creates a Title section */
|
|
107
|
+
function title(text, styles) {
|
|
108
|
+
return { Title: { text, styles } };
|
|
109
|
+
}
|
|
110
|
+
/** Creates a Subtitle section */
|
|
111
|
+
function subtitle(text, styles) {
|
|
112
|
+
return { Subtitle: { text, styles } };
|
|
113
|
+
}
|
|
114
|
+
/** Creates a Text section */
|
|
115
|
+
function text(text, styles) {
|
|
116
|
+
return { Text: { text, styles } };
|
|
117
|
+
}
|
|
118
|
+
/** Creates a Line separator section */
|
|
119
|
+
function line(character = '-') {
|
|
120
|
+
return { Line: { character } };
|
|
121
|
+
}
|
|
122
|
+
/** Creates a Feed section */
|
|
123
|
+
function feed(value, feed_type = 'lines') {
|
|
124
|
+
return { Feed: { feed_type, value } };
|
|
125
|
+
}
|
|
126
|
+
/** Creates a Cut section */
|
|
127
|
+
function cut(mode = 'partial', feedLines = 4) {
|
|
128
|
+
return { Cut: { mode, feed: feedLines } };
|
|
129
|
+
}
|
|
130
|
+
/** Creates a GlobalStyles section — affects all subsequent sections until changed */
|
|
131
|
+
function globalStyles(styles) {
|
|
132
|
+
return { GlobalStyles: styles };
|
|
133
|
+
}
|
|
134
|
+
/** Creates a Beep section */
|
|
135
|
+
function beep(times = 1, duration = 3) {
|
|
136
|
+
return { Beep: { times, duration } };
|
|
137
|
+
}
|
|
138
|
+
/** Creates a Drawer section */
|
|
139
|
+
function drawer(pin = 2, pulse_time = 120) {
|
|
140
|
+
return { Drawer: { pin, pulse_time } };
|
|
141
|
+
}
|
|
142
|
+
/** Creates a Table section */
|
|
143
|
+
function table(columns, body, options) {
|
|
144
|
+
return {
|
|
145
|
+
Table: {
|
|
146
|
+
columns,
|
|
147
|
+
body,
|
|
148
|
+
column_widths: options?.column_widths,
|
|
149
|
+
header: options?.header,
|
|
150
|
+
truncate: options?.truncate ?? true,
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/** Creates a QR section */
|
|
155
|
+
function qr(data, options) {
|
|
156
|
+
return {
|
|
157
|
+
Qr: {
|
|
158
|
+
data,
|
|
159
|
+
size: options?.size ?? 6,
|
|
160
|
+
error_correction: options?.error_correction ?? 'M',
|
|
161
|
+
model: options?.model ?? 2,
|
|
162
|
+
align: options?.align,
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
/** Creates a Barcode section */
|
|
167
|
+
function barcode(data, barcode_type = 'CODE128', options) {
|
|
168
|
+
return {
|
|
169
|
+
Barcode: {
|
|
170
|
+
data,
|
|
171
|
+
barcode_type,
|
|
172
|
+
width: options?.width ?? 3,
|
|
173
|
+
height: options?.height ?? 80,
|
|
174
|
+
text_position: options?.text_position ?? 'below',
|
|
175
|
+
align: options?.align,
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/** Creates a DataMatrix section */
|
|
180
|
+
function dataMatrix(data, size = 6) {
|
|
181
|
+
return {
|
|
182
|
+
DataMatrix: {
|
|
183
|
+
data,
|
|
184
|
+
size,
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/** Creates a PDF417 section */
|
|
189
|
+
function pdf417(data, options) {
|
|
190
|
+
return {
|
|
191
|
+
Pdf417: {
|
|
192
|
+
data,
|
|
193
|
+
columns: options?.columns ?? 0,
|
|
194
|
+
rows: options?.rows ?? 0,
|
|
195
|
+
width: options?.width ?? 2,
|
|
196
|
+
height: options?.height ?? 3,
|
|
197
|
+
error_correction: options?.error_correction ?? 2,
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
/** Creates an Image section */
|
|
202
|
+
function image(data, options) {
|
|
203
|
+
return {
|
|
204
|
+
Image: {
|
|
205
|
+
data,
|
|
206
|
+
max_width: options?.max_width ?? 0,
|
|
207
|
+
align: options?.align ?? 'center',
|
|
208
|
+
dithering: options?.dithering ?? true,
|
|
209
|
+
size: options?.size ?? 'normal',
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
/** Creates a Logo section */
|
|
214
|
+
function logo(key_code, mode = 'normal') {
|
|
215
|
+
return {
|
|
216
|
+
Logo: {
|
|
217
|
+
key_code,
|
|
218
|
+
mode,
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
// ─── Commands ─────────────────────────────────────────────────────────────────
|
|
223
|
+
/**
|
|
224
|
+
* Sends a print job to the specified thermal printer.
|
|
225
|
+
* @throws {string} Error message from the printer or document generation if the job fails.
|
|
226
|
+
*/
|
|
5
227
|
async function print_thermal_printer(printJobRequest) {
|
|
6
|
-
|
|
7
|
-
printJobRequest
|
|
228
|
+
await core.invoke('plugin:thermal-printer|print_thermal_printer', {
|
|
229
|
+
printJobRequest,
|
|
8
230
|
});
|
|
9
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Returns the list of available thermal printers on the current system.
|
|
234
|
+
* @throws {string} Error message if printer enumeration fails.
|
|
235
|
+
*/
|
|
10
236
|
async function list_thermal_printers() {
|
|
11
237
|
return await core.invoke('plugin:thermal-printer|list_thermal_printers');
|
|
12
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* Sends a test print job to verify the printer is working correctly.
|
|
241
|
+
* @throws {string} Error message from the printer or document generation if the job fails.
|
|
242
|
+
*/
|
|
13
243
|
async function test_thermal_printer(testPrintRequest) {
|
|
14
|
-
|
|
244
|
+
await core.invoke('plugin:thermal-printer|test_thermal_printer', {
|
|
15
245
|
printTestRequest: testPrintRequest,
|
|
16
246
|
});
|
|
17
247
|
}
|
|
18
248
|
|
|
249
|
+
exports.BARCODE_TEXT_POSITION = BARCODE_TEXT_POSITION;
|
|
250
|
+
exports.BARCODE_TYPE = BARCODE_TYPE;
|
|
251
|
+
exports.CODE_PAGE = CODE_PAGE;
|
|
252
|
+
exports.CUT_MODE = CUT_MODE;
|
|
253
|
+
exports.DEFAULT_PAPER_SIZE = DEFAULT_PAPER_SIZE;
|
|
254
|
+
exports.IMAGE_MODE = IMAGE_MODE;
|
|
255
|
+
exports.PAPER_SIZE_CHARS_PER_LINE = PAPER_SIZE_CHARS_PER_LINE;
|
|
256
|
+
exports.PAPER_SIZE_PIXELS_WIDTH = PAPER_SIZE_PIXELS_WIDTH;
|
|
257
|
+
exports.QR_ERROR_CORRECTION = QR_ERROR_CORRECTION;
|
|
258
|
+
exports.TEXT_ALIGN = TEXT_ALIGN;
|
|
259
|
+
exports.TEXT_FONT = TEXT_FONT;
|
|
260
|
+
exports.TEXT_SIZE = TEXT_SIZE;
|
|
261
|
+
exports.barcode = barcode;
|
|
262
|
+
exports.beep = beep;
|
|
263
|
+
exports.cut = cut;
|
|
264
|
+
exports.dataMatrix = dataMatrix;
|
|
265
|
+
exports.drawer = drawer;
|
|
266
|
+
exports.feed = feed;
|
|
267
|
+
exports.getPaperSizeCharsPerLine = getPaperSizeCharsPerLine;
|
|
268
|
+
exports.getPaperSizePixelsWidth = getPaperSizePixelsWidth;
|
|
269
|
+
exports.globalStyles = globalStyles;
|
|
270
|
+
exports.image = image;
|
|
271
|
+
exports.line = line;
|
|
19
272
|
exports.list_thermal_printers = list_thermal_printers;
|
|
273
|
+
exports.logo = logo;
|
|
274
|
+
exports.pdf417 = pdf417;
|
|
20
275
|
exports.print_thermal_printer = print_thermal_printer;
|
|
276
|
+
exports.qr = qr;
|
|
277
|
+
exports.subtitle = subtitle;
|
|
278
|
+
exports.table = table;
|
|
21
279
|
exports.test_thermal_printer = test_thermal_printer;
|
|
280
|
+
exports.text = text;
|
|
281
|
+
exports.title = title;
|
package/dist-js/index.d.ts
CHANGED
|
@@ -1,19 +1,137 @@
|
|
|
1
|
-
export type PaperSize = 'Mm58' | 'Mm80';
|
|
1
|
+
export type PaperSize = 'Mm40' | 'Mm44' | 'Mm58' | 'Mm72' | 'Mm80' | 'Mm104';
|
|
2
|
+
export declare const PAPER_SIZE_CHARS_PER_LINE: Record<PaperSize, number>;
|
|
3
|
+
export declare const PAPER_SIZE_PIXELS_WIDTH: Record<PaperSize, number>;
|
|
4
|
+
export declare const DEFAULT_PAPER_SIZE: PaperSize;
|
|
5
|
+
export declare function getPaperSizeCharsPerLine(paperSize: PaperSize): number;
|
|
6
|
+
export declare function getPaperSizePixelsWidth(paperSize: PaperSize): number;
|
|
7
|
+
/**
|
|
8
|
+
* Character encoding page to use for printing.
|
|
9
|
+
* Select by language/region — no need to know ESC/POS code page numbers.
|
|
10
|
+
*
|
|
11
|
+
* | Value | Code Page | Languages |
|
|
12
|
+
* |-----------------|-----------|------------------------------------------------|
|
|
13
|
+
* | Default | CP437 | ASCII only — no accented characters |
|
|
14
|
+
* | Spanish | CP850 | Spanish, French, Italian, German, Portuguese |
|
|
15
|
+
* | French | CP850 | Alias of Spanish |
|
|
16
|
+
* | Portuguese | CP860 | Portuguese (includes ã, õ) |
|
|
17
|
+
* | CanadianFrench | CP863 | Canadian French |
|
|
18
|
+
* | Nordic | CP865 | Swedish, Norwegian, Danish, Finnish (å, ø, æ) |
|
|
19
|
+
* | WindowsLatin | CP1252 | Wide Western European coverage (includes €) |
|
|
20
|
+
* | Russian | CP866 | Russian / Cyrillic |
|
|
21
|
+
* | EasternEurope | CP852 | Polish, Czech, Slovak, Hungarian |
|
|
22
|
+
*/
|
|
23
|
+
export type CodePage = 'Default' | 'Spanish' | 'French' | 'Portuguese' | 'CanadianFrench' | 'Nordic' | 'WindowsLatin' | 'Russian' | 'EasternEurope' | 'AccentRemover';
|
|
24
|
+
/** Text alignment options */
|
|
25
|
+
export type TextAlign = 'left' | 'center' | 'right';
|
|
26
|
+
/** Text size options */
|
|
27
|
+
export type TextSize = 'normal' | 'height' | 'width' | 'double';
|
|
28
|
+
/** Font options */
|
|
29
|
+
export type TextFont = 'A' | 'B' | 'C';
|
|
30
|
+
/** Barcode text position options */
|
|
31
|
+
export type BarcodeTextPosition = 'none' | 'above' | 'below' | 'both';
|
|
32
|
+
/** Barcode type options */
|
|
33
|
+
export type BarcodeType = 'UPC-A' | 'UPC-E' | 'EAN13' | 'EAN8' | 'CODE39' | 'ITF' | 'CODABAR' | 'CODE93' | 'CODE128';
|
|
34
|
+
/** QR error correction level */
|
|
35
|
+
export type QrErrorCorrection = 'L' | 'M' | 'Q' | 'H';
|
|
36
|
+
/** Image size mode */
|
|
37
|
+
export type ImageMode = 'normal' | 'double_width' | 'double_height' | 'quadruple';
|
|
38
|
+
/** Feed type */
|
|
39
|
+
export type FeedType = 'lines' | 'dots' | 'line_feed';
|
|
40
|
+
/** Cut mode */
|
|
41
|
+
export type CutMode = 'full' | 'partial' | 'partial_alt' | 'partial_alt2';
|
|
42
|
+
export declare const TEXT_ALIGN: {
|
|
43
|
+
readonly LEFT: TextAlign;
|
|
44
|
+
readonly CENTER: TextAlign;
|
|
45
|
+
readonly RIGHT: TextAlign;
|
|
46
|
+
};
|
|
47
|
+
export declare const TEXT_SIZE: {
|
|
48
|
+
readonly NORMAL: TextSize;
|
|
49
|
+
readonly HEIGHT: TextSize;
|
|
50
|
+
readonly WIDTH: TextSize;
|
|
51
|
+
readonly DOUBLE: TextSize;
|
|
52
|
+
};
|
|
53
|
+
export declare const TEXT_FONT: {
|
|
54
|
+
readonly A: TextFont;
|
|
55
|
+
readonly B: TextFont;
|
|
56
|
+
readonly C: TextFont;
|
|
57
|
+
};
|
|
58
|
+
export declare const BARCODE_TYPE: {
|
|
59
|
+
readonly UPC_A: BarcodeType;
|
|
60
|
+
readonly UPC_E: BarcodeType;
|
|
61
|
+
readonly EAN13: BarcodeType;
|
|
62
|
+
readonly EAN8: BarcodeType;
|
|
63
|
+
readonly CODE39: BarcodeType;
|
|
64
|
+
readonly ITF: BarcodeType;
|
|
65
|
+
readonly CODABAR: BarcodeType;
|
|
66
|
+
readonly CODE93: BarcodeType;
|
|
67
|
+
readonly CODE128: BarcodeType;
|
|
68
|
+
};
|
|
69
|
+
export declare const BARCODE_TEXT_POSITION: {
|
|
70
|
+
readonly NONE: BarcodeTextPosition;
|
|
71
|
+
readonly ABOVE: BarcodeTextPosition;
|
|
72
|
+
readonly BELOW: BarcodeTextPosition;
|
|
73
|
+
readonly BOTH: BarcodeTextPosition;
|
|
74
|
+
};
|
|
75
|
+
export declare const QR_ERROR_CORRECTION: {
|
|
76
|
+
/** Low — 7% recovery */
|
|
77
|
+
readonly L: QrErrorCorrection;
|
|
78
|
+
/** Medium — 15% recovery (recommended default) */
|
|
79
|
+
readonly M: QrErrorCorrection;
|
|
80
|
+
/** Quartile — 25% recovery */
|
|
81
|
+
readonly Q: QrErrorCorrection;
|
|
82
|
+
/** High — 30% recovery */
|
|
83
|
+
readonly H: QrErrorCorrection;
|
|
84
|
+
};
|
|
85
|
+
export declare const IMAGE_MODE: {
|
|
86
|
+
readonly NORMAL: ImageMode;
|
|
87
|
+
readonly DOUBLE_WIDTH: ImageMode;
|
|
88
|
+
readonly DOUBLE_HEIGHT: ImageMode;
|
|
89
|
+
readonly QUADRUPLE: ImageMode;
|
|
90
|
+
};
|
|
91
|
+
export declare const CUT_MODE: {
|
|
92
|
+
readonly FULL: CutMode;
|
|
93
|
+
readonly PARTIAL: CutMode;
|
|
94
|
+
};
|
|
95
|
+
export declare const CODE_PAGE: {
|
|
96
|
+
/** CP437 — ASCII only, no accented characters */
|
|
97
|
+
readonly DEFAULT: CodePage;
|
|
98
|
+
/** CP850 — Spanish, French, Italian, German */
|
|
99
|
+
readonly SPANISH: CodePage;
|
|
100
|
+
/** CP850 — Alias of Spanish */
|
|
101
|
+
readonly FRENCH: CodePage;
|
|
102
|
+
/** CP860 — Portuguese (ã, õ) */
|
|
103
|
+
readonly PORTUGUESE: CodePage;
|
|
104
|
+
/** CP863 — Canadian French */
|
|
105
|
+
readonly CANADIAN_FRENCH: CodePage;
|
|
106
|
+
/** CP865 — Nordic languages (å, ø, æ) */
|
|
107
|
+
readonly NORDIC: CodePage;
|
|
108
|
+
/** CP1252 — Wide Western European, includes € */
|
|
109
|
+
readonly WINDOWS_LATIN: CodePage;
|
|
110
|
+
/** CP866 — Russian / Cyrillic */
|
|
111
|
+
readonly RUSSIAN: CodePage;
|
|
112
|
+
/** CP852 — Eastern Europe (Polish, Czech, Slovak, Hungarian) */
|
|
113
|
+
readonly EASTERN_EUROPE: CodePage;
|
|
114
|
+
/** Strips accents and special chars to plain ASCII. Use when the printer
|
|
115
|
+
* ignores ESC t commands. á→a, é→e, ñ→n, ß→ss, ¿→?, €→EUR, etc. */
|
|
116
|
+
readonly ACCENT_REMOVER: CodePage;
|
|
117
|
+
};
|
|
2
118
|
export interface PrinterOptions {
|
|
3
119
|
cut_paper: boolean;
|
|
4
120
|
beep: boolean;
|
|
5
121
|
open_cash_drawer: boolean;
|
|
122
|
+
/** Character encoding for the printer. Default: 'Default' (ASCII only). */
|
|
123
|
+
code_page?: CodePage;
|
|
6
124
|
}
|
|
7
125
|
export interface GlobalStyles {
|
|
8
126
|
bold?: boolean;
|
|
9
127
|
underline?: boolean;
|
|
10
|
-
align?:
|
|
128
|
+
align?: TextAlign;
|
|
11
129
|
italic?: boolean;
|
|
12
130
|
invert?: boolean;
|
|
13
|
-
font?:
|
|
131
|
+
font?: TextFont;
|
|
14
132
|
rotate?: boolean;
|
|
15
133
|
upside_down?: boolean;
|
|
16
|
-
size?:
|
|
134
|
+
size?: TextSize;
|
|
17
135
|
}
|
|
18
136
|
export interface Title {
|
|
19
137
|
text: string;
|
|
@@ -28,19 +146,21 @@ export interface Text {
|
|
|
28
146
|
styles?: GlobalStyles;
|
|
29
147
|
}
|
|
30
148
|
export interface Feed {
|
|
31
|
-
feed_type:
|
|
149
|
+
feed_type: FeedType;
|
|
32
150
|
value: number;
|
|
33
151
|
}
|
|
34
152
|
export interface Cut {
|
|
35
|
-
mode:
|
|
153
|
+
mode: CutMode;
|
|
36
154
|
feed: number;
|
|
37
155
|
}
|
|
38
156
|
export interface Beep {
|
|
157
|
+
/** Number of beeps (1–9) */
|
|
39
158
|
times: number;
|
|
159
|
+
/** Duration per beep in ms (1–255) */
|
|
40
160
|
duration: number;
|
|
41
161
|
}
|
|
42
162
|
export interface Drawer {
|
|
43
|
-
pin:
|
|
163
|
+
pin: 2 | 5;
|
|
44
164
|
pulse_time: number;
|
|
45
165
|
}
|
|
46
166
|
export interface Table {
|
|
@@ -52,43 +172,56 @@ export interface Table {
|
|
|
52
172
|
}
|
|
53
173
|
export interface Qr {
|
|
54
174
|
data: string;
|
|
175
|
+
/** Module size 1–16 (default 6) */
|
|
55
176
|
size: number;
|
|
56
|
-
error_correction:
|
|
57
|
-
model:
|
|
58
|
-
align?:
|
|
177
|
+
error_correction: QrErrorCorrection;
|
|
178
|
+
model: 1 | 2;
|
|
179
|
+
align?: TextAlign;
|
|
59
180
|
}
|
|
60
181
|
export interface Barcode {
|
|
61
182
|
data: string;
|
|
62
|
-
barcode_type:
|
|
183
|
+
barcode_type: BarcodeType;
|
|
184
|
+
/** Bar width 2–6 */
|
|
63
185
|
width: number;
|
|
186
|
+
/** Bar height in dots (1–255) */
|
|
64
187
|
height: number;
|
|
65
|
-
text_position:
|
|
66
|
-
align?:
|
|
188
|
+
text_position: BarcodeTextPosition;
|
|
189
|
+
align?: TextAlign;
|
|
67
190
|
}
|
|
68
191
|
export interface DataMatrixModel {
|
|
69
192
|
data: string;
|
|
193
|
+
/** Module size 1–16 */
|
|
70
194
|
size: number;
|
|
71
195
|
}
|
|
72
196
|
export interface Pdf417 {
|
|
73
197
|
data: string;
|
|
198
|
+
/** Columns 0 (auto) or 1–30 */
|
|
74
199
|
columns: number;
|
|
200
|
+
/** Rows 0 (auto) or 3–90 */
|
|
75
201
|
rows: number;
|
|
202
|
+
/** Module width 2–8 */
|
|
76
203
|
width: number;
|
|
204
|
+
/** Row height 2–8 */
|
|
77
205
|
height: number;
|
|
206
|
+
/** Error correction level 0–8 */
|
|
78
207
|
error_correction: number;
|
|
79
208
|
}
|
|
80
209
|
export interface Image {
|
|
210
|
+
/** Base64 encoded image (with or without data URI prefix) */
|
|
81
211
|
data: string;
|
|
212
|
+
/** Max width in pixels. 0 = use full paper width. */
|
|
82
213
|
max_width: number;
|
|
83
|
-
align:
|
|
214
|
+
align: TextAlign;
|
|
84
215
|
dithering: boolean;
|
|
85
|
-
size:
|
|
216
|
+
size: ImageMode;
|
|
86
217
|
}
|
|
87
218
|
export interface Logo {
|
|
219
|
+
/** NV memory key code (1–255) */
|
|
88
220
|
key_code: number;
|
|
89
|
-
mode:
|
|
221
|
+
mode: ImageMode;
|
|
90
222
|
}
|
|
91
223
|
export interface Line {
|
|
224
|
+
/** Single character to repeat across the paper width (default '-') */
|
|
92
225
|
character: string;
|
|
93
226
|
}
|
|
94
227
|
export type PrintSections = {
|
|
@@ -139,6 +272,8 @@ export interface PrinterInfo {
|
|
|
139
272
|
export interface TestPrintRequest {
|
|
140
273
|
printer_info: PrintJobRequest;
|
|
141
274
|
include_text?: boolean;
|
|
275
|
+
include_custom_text?: boolean;
|
|
276
|
+
custom_text?: string | null;
|
|
142
277
|
include_text_styles?: boolean;
|
|
143
278
|
include_alignment?: boolean;
|
|
144
279
|
include_columns?: boolean;
|
|
@@ -156,6 +291,75 @@ export interface TestPrintRequest {
|
|
|
156
291
|
test_invert?: boolean;
|
|
157
292
|
test_rotate?: boolean;
|
|
158
293
|
}
|
|
159
|
-
|
|
294
|
+
/** Creates a Title section */
|
|
295
|
+
export declare function title(text: string, styles?: GlobalStyles): PrintSections;
|
|
296
|
+
/** Creates a Subtitle section */
|
|
297
|
+
export declare function subtitle(text: string, styles?: GlobalStyles): PrintSections;
|
|
298
|
+
/** Creates a Text section */
|
|
299
|
+
export declare function text(text: string, styles?: GlobalStyles): PrintSections;
|
|
300
|
+
/** Creates a Line separator section */
|
|
301
|
+
export declare function line(character?: string): PrintSections;
|
|
302
|
+
/** Creates a Feed section */
|
|
303
|
+
export declare function feed(value: number, feed_type?: FeedType): PrintSections;
|
|
304
|
+
/** Creates a Cut section */
|
|
305
|
+
export declare function cut(mode?: CutMode, feedLines?: number): PrintSections;
|
|
306
|
+
/** Creates a GlobalStyles section — affects all subsequent sections until changed */
|
|
307
|
+
export declare function globalStyles(styles: GlobalStyles): PrintSections;
|
|
308
|
+
/** Creates a Beep section */
|
|
309
|
+
export declare function beep(times?: number, duration?: number): PrintSections;
|
|
310
|
+
/** Creates a Drawer section */
|
|
311
|
+
export declare function drawer(pin?: 2 | 5, pulse_time?: number): PrintSections;
|
|
312
|
+
/** Creates a Table section */
|
|
313
|
+
export declare function table(columns: number, body: Text[][], options?: {
|
|
314
|
+
column_widths?: number[];
|
|
315
|
+
header?: Text[];
|
|
316
|
+
truncate?: boolean;
|
|
317
|
+
}): PrintSections;
|
|
318
|
+
/** Creates a QR section */
|
|
319
|
+
export declare function qr(data: string, options?: {
|
|
320
|
+
size?: number;
|
|
321
|
+
error_correction?: QrErrorCorrection;
|
|
322
|
+
model?: 1 | 2;
|
|
323
|
+
align?: TextAlign;
|
|
324
|
+
}): PrintSections;
|
|
325
|
+
/** Creates a Barcode section */
|
|
326
|
+
export declare function barcode(data: string, barcode_type?: BarcodeType, options?: {
|
|
327
|
+
width?: number;
|
|
328
|
+
height?: number;
|
|
329
|
+
text_position?: BarcodeTextPosition;
|
|
330
|
+
align?: TextAlign;
|
|
331
|
+
}): PrintSections;
|
|
332
|
+
/** Creates a DataMatrix section */
|
|
333
|
+
export declare function dataMatrix(data: string, size?: number): PrintSections;
|
|
334
|
+
/** Creates a PDF417 section */
|
|
335
|
+
export declare function pdf417(data: string, options?: {
|
|
336
|
+
columns?: number;
|
|
337
|
+
rows?: number;
|
|
338
|
+
width?: number;
|
|
339
|
+
height?: number;
|
|
340
|
+
error_correction?: number;
|
|
341
|
+
}): PrintSections;
|
|
342
|
+
/** Creates an Image section */
|
|
343
|
+
export declare function image(data: string, options?: {
|
|
344
|
+
max_width?: number;
|
|
345
|
+
align?: TextAlign;
|
|
346
|
+
dithering?: boolean;
|
|
347
|
+
size?: ImageMode;
|
|
348
|
+
}): PrintSections;
|
|
349
|
+
/** Creates a Logo section */
|
|
350
|
+
export declare function logo(key_code: number, mode?: ImageMode): PrintSections;
|
|
351
|
+
/**
|
|
352
|
+
* Sends a print job to the specified thermal printer.
|
|
353
|
+
* @throws {string} Error message from the printer or document generation if the job fails.
|
|
354
|
+
*/
|
|
355
|
+
export declare function print_thermal_printer(printJobRequest: PrintJobRequest): Promise<void>;
|
|
356
|
+
/**
|
|
357
|
+
* Returns the list of available thermal printers on the current system.
|
|
358
|
+
* @throws {string} Error message if printer enumeration fails.
|
|
359
|
+
*/
|
|
160
360
|
export declare function list_thermal_printers(): Promise<PrinterInfo[]>;
|
|
161
|
-
|
|
361
|
+
/**
|
|
362
|
+
* Sends a test print job to verify the printer is working correctly.
|
|
363
|
+
* @throws {string} Error message from the printer or document generation if the job fails.
|
|
364
|
+
*/
|
|
365
|
+
export declare function test_thermal_printer(testPrintRequest: TestPrintRequest): Promise<void>;
|