tauri-plugin-thermal-printer 1.3.0 → 1.3.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 +54 -15
- package/dist-js/code-page.contract.d.ts +1 -0
- package/dist-js/encode.d.ts +44 -0
- package/dist-js/index.cjs +45 -11
- package/dist-js/index.d.ts +16 -19
- package/dist-js/index.js +45 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -274,7 +274,7 @@ Send a print test to a specific printer to verify functionality.
|
|
|
274
274
|
|
|
275
275
|
#### Request:
|
|
276
276
|
```typescript
|
|
277
|
-
import { test_thermal_printer, type TestPrintRequest } from "tauri-plugin-thermal-printer";
|
|
277
|
+
import { ENCODE, test_thermal_printer, type TestPrintRequest } from "tauri-plugin-thermal-printer";
|
|
278
278
|
|
|
279
279
|
try { await test_thermal_printer({
|
|
280
280
|
"printer_info": {
|
|
@@ -283,7 +283,12 @@ try { await test_thermal_printer({
|
|
|
283
283
|
"options": {
|
|
284
284
|
"cut_paper": true,
|
|
285
285
|
"beep": true,
|
|
286
|
-
"open_cash_drawer": false
|
|
286
|
+
"open_cash_drawer": false,
|
|
287
|
+
"code_page": {
|
|
288
|
+
"code_page": 6,
|
|
289
|
+
"encode": ENCODE.WINDOWS_1252,
|
|
290
|
+
"use_gbk": false
|
|
291
|
+
}
|
|
287
292
|
},
|
|
288
293
|
"sections": [] // it's not going to print anything
|
|
289
294
|
},
|
|
@@ -341,7 +346,7 @@ Print a personalized document with the specified sections.
|
|
|
341
346
|
|
|
342
347
|
#### Request:
|
|
343
348
|
```typescript
|
|
344
|
-
import { print_thermal_printer, type PrintJobRequest } from "tauri-plugin-thermal-printer";
|
|
349
|
+
import { ENCODE, print_thermal_printer, type PrintJobRequest } from "tauri-plugin-thermal-printer";
|
|
345
350
|
|
|
346
351
|
try { await print_thermal_printer({
|
|
347
352
|
"printer": "TM-T20II",
|
|
@@ -349,7 +354,12 @@ try { await print_thermal_printer({
|
|
|
349
354
|
"options": {
|
|
350
355
|
"cut_paper": true,
|
|
351
356
|
"beep": false,
|
|
352
|
-
"open_cash_drawer": false
|
|
357
|
+
"open_cash_drawer": false,
|
|
358
|
+
"code_page": {
|
|
359
|
+
"code_page": 6,
|
|
360
|
+
"encode": ENCODE.WINDOWS_1252,
|
|
361
|
+
"use_gbk": false
|
|
362
|
+
}
|
|
353
363
|
},
|
|
354
364
|
"sections": [
|
|
355
365
|
{"Title": {"text": "My Business"}},
|
|
@@ -384,7 +394,7 @@ Returns `Promise<void>`. Resolves when printing completes successfully. **Throws
|
|
|
384
394
|
| `options.cut_paper` | boolean | ❌ No | Cut paper after printing (default: `true`) |
|
|
385
395
|
| `options.beep` | boolean | ❌ No | Beep after printing (default: `false`) |
|
|
386
396
|
| `options.open_cash_drawer` | boolean | ❌ No | Open cash drawer after printing (default: `false`) |
|
|
387
|
-
| `options.code_page` | CodePage |
|
|
397
|
+
| `options.code_page` | CodePage | ✅ Yes | Required ESC/POS page selection plus host-side encoding strategy — see [CodePage](#codepage) |
|
|
388
398
|
| `sections` | array | ✅ Yes | Array of sections to print (see [Section Types](#section-types)) |
|
|
389
399
|
|
|
390
400
|
#### Paper Sizes
|
|
@@ -881,25 +891,50 @@ The plugin exports typed constants and builder functions so you never have to ty
|
|
|
881
891
|
|
|
882
892
|
Set the character encoding once in `PrinterOptions.code_page` and all text sections (`Title`, `Subtitle`, `Text`, `Table`) will use it automatically.
|
|
883
893
|
|
|
884
|
-
Each printer model assigns its own
|
|
894
|
+
Each printer model assigns its own `ESC t n` values, so `CodePage.code_page` accepts the raw page number directly. `CodePage.encode` controls the host-side encoding used before bytes are sent to the printer. `CodePage.use_gbk` explicitly controls whether characters that the selected `encode` cannot represent should be retried with GBK before falling back to the original UTF-8 bytes.
|
|
885
895
|
|
|
886
896
|
```typescript
|
|
887
|
-
import {
|
|
897
|
+
import { ENCODE, type CodePage } from "tauri-plugin-thermal-printer";
|
|
888
898
|
|
|
889
899
|
const options = {
|
|
890
900
|
cut_paper: true,
|
|
891
901
|
beep: false,
|
|
892
902
|
open_cash_drawer: false,
|
|
893
|
-
code_page:
|
|
903
|
+
code_page: {
|
|
904
|
+
code_page: 6,
|
|
905
|
+
encode: ENCODE.WINDOWS_1252,
|
|
906
|
+
use_gbk: false,
|
|
907
|
+
}, // sends ESC t 6
|
|
894
908
|
};
|
|
895
909
|
```
|
|
896
910
|
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
|
900
|
-
|
|
911
|
+
`CodePage` fields:
|
|
912
|
+
|
|
913
|
+
| Field | Required | Description |
|
|
914
|
+
|---|---|---|
|
|
915
|
+
| `code_page` | ✅ Yes | Raw `ESC t n` value sent to the printer. |
|
|
916
|
+
| `encode` | ❌ No | Host-side encoding strategy. Defaults to `ENCODE.ACCENT_REMOVER`. |
|
|
917
|
+
| `use_gbk` | ❌ No | Retries GBK for characters that `encode` cannot represent before falling back to the original UTF-8 bytes. Defaults to `false`. |
|
|
918
|
+
|
|
919
|
+
`ENCODE.ACCENT_REMOVER`:
|
|
901
920
|
|
|
902
|
-
|
|
921
|
+
- Transliterates accented characters to ASCII before any optional GBK retry
|
|
922
|
+
and final UTF-8 passthrough.
|
|
923
|
+
- Useful when the printer does not have a reliable legacy code page for your
|
|
924
|
+
text.
|
|
925
|
+
- Examples: `á -> a`, `ß -> ss`, `€ -> EUR`.
|
|
926
|
+
|
|
927
|
+
All other `ENCODE.*` values come directly from
|
|
928
|
+
[`encoding_rs` statics](https://docs.rs/encoding_rs/latest/encoding_rs/#statics).
|
|
929
|
+
Use them with the same uppercase names exposed by the package.
|
|
930
|
+
|
|
931
|
+
Examples:
|
|
932
|
+
|
|
933
|
+
- `ENCODE.WINDOWS_1252` for Western European text
|
|
934
|
+
- `ENCODE.GBK` for GBK output
|
|
935
|
+
- `ENCODE.SHIFT_JIS` for Shift JIS output
|
|
936
|
+
|
|
937
|
+
> **Note**: `options.code_page` is required. If the selected `encode` cannot represent a character, the plugin retries GBK only when `use_gbk` is `true`; otherwise it silently emits the original UTF-8 bytes for that character.
|
|
903
938
|
|
|
904
939
|
---
|
|
905
940
|
|
|
@@ -1020,13 +1055,13 @@ import {
|
|
|
1020
1055
|
pdf417,
|
|
1021
1056
|
image,
|
|
1022
1057
|
logo,
|
|
1058
|
+
ENCODE,
|
|
1023
1059
|
TEXT_ALIGN,
|
|
1024
1060
|
TEXT_SIZE,
|
|
1025
1061
|
BARCODE_TYPE,
|
|
1026
1062
|
BARCODE_TEXT_POSITION,
|
|
1027
1063
|
QR_ERROR_CORRECTION,
|
|
1028
1064
|
IMAGE_MODE,
|
|
1029
|
-
CODE_PAGE,
|
|
1030
1065
|
} from "tauri-plugin-thermal-printer";
|
|
1031
1066
|
|
|
1032
1067
|
const job: PrintJobRequest = {
|
|
@@ -1036,7 +1071,11 @@ const job: PrintJobRequest = {
|
|
|
1036
1071
|
cut_paper: true,
|
|
1037
1072
|
beep: false,
|
|
1038
1073
|
open_cash_drawer: false,
|
|
1039
|
-
code_page:
|
|
1074
|
+
code_page: {
|
|
1075
|
+
code_page: 6,
|
|
1076
|
+
encode: ENCODE.WINDOWS_1252,
|
|
1077
|
+
use_gbk: false,
|
|
1078
|
+
},
|
|
1040
1079
|
},
|
|
1041
1080
|
sections: [
|
|
1042
1081
|
globalStyles({ align: TEXT_ALIGN.LEFT }),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare const ENCODE: {
|
|
2
|
+
readonly BIG5: "BIG5";
|
|
3
|
+
readonly EUC_JP: "EUC_JP";
|
|
4
|
+
readonly EUC_KR: "EUC_KR";
|
|
5
|
+
readonly GBK: "GBK";
|
|
6
|
+
readonly IBM866: "IBM866";
|
|
7
|
+
readonly ISO_2022_JP: "ISO_2022_JP";
|
|
8
|
+
readonly ISO_8859_10: "ISO_8859_10";
|
|
9
|
+
readonly ISO_8859_13: "ISO_8859_13";
|
|
10
|
+
readonly ISO_8859_14: "ISO_8859_14";
|
|
11
|
+
readonly ISO_8859_15: "ISO_8859_15";
|
|
12
|
+
readonly ISO_8859_16: "ISO_8859_16";
|
|
13
|
+
readonly ISO_8859_2: "ISO_8859_2";
|
|
14
|
+
readonly ISO_8859_3: "ISO_8859_3";
|
|
15
|
+
readonly ISO_8859_4: "ISO_8859_4";
|
|
16
|
+
readonly ISO_8859_5: "ISO_8859_5";
|
|
17
|
+
readonly ISO_8859_6: "ISO_8859_6";
|
|
18
|
+
readonly ISO_8859_7: "ISO_8859_7";
|
|
19
|
+
readonly ISO_8859_8: "ISO_8859_8";
|
|
20
|
+
readonly ISO_8859_8_I: "ISO_8859_8_I";
|
|
21
|
+
readonly KOI8_R: "KOI8_R";
|
|
22
|
+
readonly KOI8_U: "KOI8_U";
|
|
23
|
+
readonly SHIFT_JIS: "SHIFT_JIS";
|
|
24
|
+
readonly UTF_16BE: "UTF_16BE";
|
|
25
|
+
readonly UTF_16LE: "UTF_16LE";
|
|
26
|
+
readonly UTF_8: "UTF_8";
|
|
27
|
+
readonly GB18030: "GB18030";
|
|
28
|
+
readonly MACINTOSH: "MACINTOSH";
|
|
29
|
+
readonly REPLACEMENT: "REPLACEMENT";
|
|
30
|
+
readonly WINDOWS_1250: "WINDOWS_1250";
|
|
31
|
+
readonly WINDOWS_1251: "WINDOWS_1251";
|
|
32
|
+
readonly WINDOWS_1252: "WINDOWS_1252";
|
|
33
|
+
readonly WINDOWS_1253: "WINDOWS_1253";
|
|
34
|
+
readonly WINDOWS_1254: "WINDOWS_1254";
|
|
35
|
+
readonly WINDOWS_1255: "WINDOWS_1255";
|
|
36
|
+
readonly WINDOWS_1256: "WINDOWS_1256";
|
|
37
|
+
readonly WINDOWS_1257: "WINDOWS_1257";
|
|
38
|
+
readonly WINDOWS_1258: "WINDOWS_1258";
|
|
39
|
+
readonly WINDOWS_874: "WINDOWS_874";
|
|
40
|
+
readonly X_MAC_CYRILLIC: "X_MAC_CYRILLIC";
|
|
41
|
+
readonly X_USER_DEFINED: "X_USER_DEFINED";
|
|
42
|
+
readonly ACCENT_REMOVER: "ACCENT_REMOVER";
|
|
43
|
+
};
|
|
44
|
+
export type Encode = typeof ENCODE[keyof typeof ENCODE];
|
package/dist-js/index.cjs
CHANGED
|
@@ -2,6 +2,50 @@
|
|
|
2
2
|
|
|
3
3
|
var core = require('@tauri-apps/api/core');
|
|
4
4
|
|
|
5
|
+
const ENCODE = {
|
|
6
|
+
BIG5: 'BIG5',
|
|
7
|
+
EUC_JP: 'EUC_JP',
|
|
8
|
+
EUC_KR: 'EUC_KR',
|
|
9
|
+
GBK: 'GBK',
|
|
10
|
+
IBM866: 'IBM866',
|
|
11
|
+
ISO_2022_JP: 'ISO_2022_JP',
|
|
12
|
+
ISO_8859_10: 'ISO_8859_10',
|
|
13
|
+
ISO_8859_13: 'ISO_8859_13',
|
|
14
|
+
ISO_8859_14: 'ISO_8859_14',
|
|
15
|
+
ISO_8859_15: 'ISO_8859_15',
|
|
16
|
+
ISO_8859_16: 'ISO_8859_16',
|
|
17
|
+
ISO_8859_2: 'ISO_8859_2',
|
|
18
|
+
ISO_8859_3: 'ISO_8859_3',
|
|
19
|
+
ISO_8859_4: 'ISO_8859_4',
|
|
20
|
+
ISO_8859_5: 'ISO_8859_5',
|
|
21
|
+
ISO_8859_6: 'ISO_8859_6',
|
|
22
|
+
ISO_8859_7: 'ISO_8859_7',
|
|
23
|
+
ISO_8859_8: 'ISO_8859_8',
|
|
24
|
+
ISO_8859_8_I: 'ISO_8859_8_I',
|
|
25
|
+
KOI8_R: 'KOI8_R',
|
|
26
|
+
KOI8_U: 'KOI8_U',
|
|
27
|
+
SHIFT_JIS: 'SHIFT_JIS',
|
|
28
|
+
UTF_16BE: 'UTF_16BE',
|
|
29
|
+
UTF_16LE: 'UTF_16LE',
|
|
30
|
+
UTF_8: 'UTF_8',
|
|
31
|
+
GB18030: 'GB18030',
|
|
32
|
+
MACINTOSH: 'MACINTOSH',
|
|
33
|
+
REPLACEMENT: 'REPLACEMENT',
|
|
34
|
+
WINDOWS_1250: 'WINDOWS_1250',
|
|
35
|
+
WINDOWS_1251: 'WINDOWS_1251',
|
|
36
|
+
WINDOWS_1252: 'WINDOWS_1252',
|
|
37
|
+
WINDOWS_1253: 'WINDOWS_1253',
|
|
38
|
+
WINDOWS_1254: 'WINDOWS_1254',
|
|
39
|
+
WINDOWS_1255: 'WINDOWS_1255',
|
|
40
|
+
WINDOWS_1256: 'WINDOWS_1256',
|
|
41
|
+
WINDOWS_1257: 'WINDOWS_1257',
|
|
42
|
+
WINDOWS_1258: 'WINDOWS_1258',
|
|
43
|
+
WINDOWS_874: 'WINDOWS_874',
|
|
44
|
+
X_MAC_CYRILLIC: 'X_MAC_CYRILLIC',
|
|
45
|
+
X_USER_DEFINED: 'X_USER_DEFINED',
|
|
46
|
+
ACCENT_REMOVER: 'ACCENT_REMOVER',
|
|
47
|
+
};
|
|
48
|
+
|
|
5
49
|
const PAPER_SIZE_CHARS_PER_LINE = {
|
|
6
50
|
Mm40: 21,
|
|
7
51
|
Mm44: 24,
|
|
@@ -25,10 +69,6 @@ function getPaperSizeCharsPerLine(paperSize) {
|
|
|
25
69
|
function getPaperSizePixelsWidth(paperSize) {
|
|
26
70
|
return PAPER_SIZE_PIXELS_WIDTH[paperSize];
|
|
27
71
|
}
|
|
28
|
-
/** Creates a `CodePage` that sends the given ESC/POS code page number. */
|
|
29
|
-
function codePage(n) {
|
|
30
|
-
return { Page: n };
|
|
31
|
-
}
|
|
32
72
|
// ─── Convenience style presets ────────────────────────────────────────────────
|
|
33
73
|
const TEXT_ALIGN = {
|
|
34
74
|
LEFT: 'left',
|
|
@@ -83,11 +123,6 @@ const CUT_MODE = {
|
|
|
83
123
|
FULL: 'full',
|
|
84
124
|
PARTIAL: 'partial',
|
|
85
125
|
};
|
|
86
|
-
const CODE_PAGE = {
|
|
87
|
-
/** Strips accents and special chars to plain ASCII. Use when the printer
|
|
88
|
-
* ignores ESC t commands. á→a, é→e, ñ→n, ß→ss, ¿→?, €→EUR, etc. */
|
|
89
|
-
ACCENT_REMOVER: 'AccentRemover',
|
|
90
|
-
};
|
|
91
126
|
// ─── Helper builders ──────────────────────────────────────────────────────────
|
|
92
127
|
/** Creates a Title section */
|
|
93
128
|
function title(text, styles) {
|
|
@@ -234,9 +269,9 @@ async function test_thermal_printer(testPrintRequest) {
|
|
|
234
269
|
|
|
235
270
|
exports.BARCODE_TEXT_POSITION = BARCODE_TEXT_POSITION;
|
|
236
271
|
exports.BARCODE_TYPE = BARCODE_TYPE;
|
|
237
|
-
exports.CODE_PAGE = CODE_PAGE;
|
|
238
272
|
exports.CUT_MODE = CUT_MODE;
|
|
239
273
|
exports.DEFAULT_PAPER_SIZE = DEFAULT_PAPER_SIZE;
|
|
274
|
+
exports.ENCODE = ENCODE;
|
|
240
275
|
exports.IMAGE_MODE = IMAGE_MODE;
|
|
241
276
|
exports.PAPER_SIZE_CHARS_PER_LINE = PAPER_SIZE_CHARS_PER_LINE;
|
|
242
277
|
exports.PAPER_SIZE_PIXELS_WIDTH = PAPER_SIZE_PIXELS_WIDTH;
|
|
@@ -246,7 +281,6 @@ exports.TEXT_FONT = TEXT_FONT;
|
|
|
246
281
|
exports.TEXT_SIZE = TEXT_SIZE;
|
|
247
282
|
exports.barcode = barcode;
|
|
248
283
|
exports.beep = beep;
|
|
249
|
-
exports.codePage = codePage;
|
|
250
284
|
exports.cut = cut;
|
|
251
285
|
exports.dataMatrix = dataMatrix;
|
|
252
286
|
exports.drawer = drawer;
|
package/dist-js/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { Encode } from './encode';
|
|
2
|
+
export { ENCODE } from './encode';
|
|
3
|
+
export type { Encode } from './encode';
|
|
1
4
|
export type PaperSize = 'Mm40' | 'Mm44' | 'Mm58' | 'Mm72' | 'Mm80' | 'Mm104';
|
|
2
5
|
export declare const PAPER_SIZE_CHARS_PER_LINE: Record<PaperSize, number>;
|
|
3
6
|
export declare const PAPER_SIZE_PIXELS_WIDTH: Record<PaperSize, number>;
|
|
@@ -5,20 +8,19 @@ export declare const DEFAULT_PAPER_SIZE: PaperSize;
|
|
|
5
8
|
export declare function getPaperSizeCharsPerLine(paperSize: PaperSize): number;
|
|
6
9
|
export declare function getPaperSizePixelsWidth(paperSize: PaperSize): number;
|
|
7
10
|
/**
|
|
8
|
-
*
|
|
11
|
+
* ESC/POS page selection plus explicit host-side encoding behavior.
|
|
9
12
|
*
|
|
10
|
-
* - `
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* - `
|
|
14
|
-
*
|
|
15
|
-
* page. Examples: á→a, é→e, ñ→n, ß→ss, ¿→?, €→EUR.
|
|
13
|
+
* - `codepage` controls the `ESC t n` command sent to the printer.
|
|
14
|
+
* - `encode` selects the host-side encoding and defaults to
|
|
15
|
+
* `ENCODE.ACCENT_REMOVER`.
|
|
16
|
+
* - `use_gbk` controls whether unmapped non-ASCII characters may fall back
|
|
17
|
+
* to GBK. It defaults to `false`.
|
|
16
18
|
*/
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
export interface CodePage {
|
|
20
|
+
code_page: number;
|
|
21
|
+
encode?: Encode;
|
|
22
|
+
use_gbk?: boolean;
|
|
23
|
+
}
|
|
22
24
|
/** Text alignment options */
|
|
23
25
|
export type TextAlign = 'left' | 'center' | 'right';
|
|
24
26
|
/** Text size options */
|
|
@@ -90,17 +92,12 @@ export declare const CUT_MODE: {
|
|
|
90
92
|
readonly FULL: CutMode;
|
|
91
93
|
readonly PARTIAL: CutMode;
|
|
92
94
|
};
|
|
93
|
-
export declare const CODE_PAGE: {
|
|
94
|
-
/** Strips accents and special chars to plain ASCII. Use when the printer
|
|
95
|
-
* ignores ESC t commands. á→a, é→e, ñ→n, ß→ss, ¿→?, €→EUR, etc. */
|
|
96
|
-
readonly ACCENT_REMOVER: CodePage;
|
|
97
|
-
};
|
|
98
95
|
export interface PrinterOptions {
|
|
99
96
|
cut_paper: boolean;
|
|
100
97
|
beep: boolean;
|
|
101
98
|
open_cash_drawer: boolean;
|
|
102
|
-
/**
|
|
103
|
-
code_page
|
|
99
|
+
/** Required ESC/POS page plus host-side encoding strategy. */
|
|
100
|
+
code_page: CodePage;
|
|
104
101
|
}
|
|
105
102
|
export interface GlobalStyles {
|
|
106
103
|
bold?: boolean;
|
package/dist-js/index.js
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
import { invoke } from '@tauri-apps/api/core';
|
|
2
2
|
|
|
3
|
+
const ENCODE = {
|
|
4
|
+
BIG5: 'BIG5',
|
|
5
|
+
EUC_JP: 'EUC_JP',
|
|
6
|
+
EUC_KR: 'EUC_KR',
|
|
7
|
+
GBK: 'GBK',
|
|
8
|
+
IBM866: 'IBM866',
|
|
9
|
+
ISO_2022_JP: 'ISO_2022_JP',
|
|
10
|
+
ISO_8859_10: 'ISO_8859_10',
|
|
11
|
+
ISO_8859_13: 'ISO_8859_13',
|
|
12
|
+
ISO_8859_14: 'ISO_8859_14',
|
|
13
|
+
ISO_8859_15: 'ISO_8859_15',
|
|
14
|
+
ISO_8859_16: 'ISO_8859_16',
|
|
15
|
+
ISO_8859_2: 'ISO_8859_2',
|
|
16
|
+
ISO_8859_3: 'ISO_8859_3',
|
|
17
|
+
ISO_8859_4: 'ISO_8859_4',
|
|
18
|
+
ISO_8859_5: 'ISO_8859_5',
|
|
19
|
+
ISO_8859_6: 'ISO_8859_6',
|
|
20
|
+
ISO_8859_7: 'ISO_8859_7',
|
|
21
|
+
ISO_8859_8: 'ISO_8859_8',
|
|
22
|
+
ISO_8859_8_I: 'ISO_8859_8_I',
|
|
23
|
+
KOI8_R: 'KOI8_R',
|
|
24
|
+
KOI8_U: 'KOI8_U',
|
|
25
|
+
SHIFT_JIS: 'SHIFT_JIS',
|
|
26
|
+
UTF_16BE: 'UTF_16BE',
|
|
27
|
+
UTF_16LE: 'UTF_16LE',
|
|
28
|
+
UTF_8: 'UTF_8',
|
|
29
|
+
GB18030: 'GB18030',
|
|
30
|
+
MACINTOSH: 'MACINTOSH',
|
|
31
|
+
REPLACEMENT: 'REPLACEMENT',
|
|
32
|
+
WINDOWS_1250: 'WINDOWS_1250',
|
|
33
|
+
WINDOWS_1251: 'WINDOWS_1251',
|
|
34
|
+
WINDOWS_1252: 'WINDOWS_1252',
|
|
35
|
+
WINDOWS_1253: 'WINDOWS_1253',
|
|
36
|
+
WINDOWS_1254: 'WINDOWS_1254',
|
|
37
|
+
WINDOWS_1255: 'WINDOWS_1255',
|
|
38
|
+
WINDOWS_1256: 'WINDOWS_1256',
|
|
39
|
+
WINDOWS_1257: 'WINDOWS_1257',
|
|
40
|
+
WINDOWS_1258: 'WINDOWS_1258',
|
|
41
|
+
WINDOWS_874: 'WINDOWS_874',
|
|
42
|
+
X_MAC_CYRILLIC: 'X_MAC_CYRILLIC',
|
|
43
|
+
X_USER_DEFINED: 'X_USER_DEFINED',
|
|
44
|
+
ACCENT_REMOVER: 'ACCENT_REMOVER',
|
|
45
|
+
};
|
|
46
|
+
|
|
3
47
|
const PAPER_SIZE_CHARS_PER_LINE = {
|
|
4
48
|
Mm40: 21,
|
|
5
49
|
Mm44: 24,
|
|
@@ -23,10 +67,6 @@ function getPaperSizeCharsPerLine(paperSize) {
|
|
|
23
67
|
function getPaperSizePixelsWidth(paperSize) {
|
|
24
68
|
return PAPER_SIZE_PIXELS_WIDTH[paperSize];
|
|
25
69
|
}
|
|
26
|
-
/** Creates a `CodePage` that sends the given ESC/POS code page number. */
|
|
27
|
-
function codePage(n) {
|
|
28
|
-
return { Page: n };
|
|
29
|
-
}
|
|
30
70
|
// ─── Convenience style presets ────────────────────────────────────────────────
|
|
31
71
|
const TEXT_ALIGN = {
|
|
32
72
|
LEFT: 'left',
|
|
@@ -81,11 +121,6 @@ const CUT_MODE = {
|
|
|
81
121
|
FULL: 'full',
|
|
82
122
|
PARTIAL: 'partial',
|
|
83
123
|
};
|
|
84
|
-
const CODE_PAGE = {
|
|
85
|
-
/** Strips accents and special chars to plain ASCII. Use when the printer
|
|
86
|
-
* ignores ESC t commands. á→a, é→e, ñ→n, ß→ss, ¿→?, €→EUR, etc. */
|
|
87
|
-
ACCENT_REMOVER: 'AccentRemover',
|
|
88
|
-
};
|
|
89
124
|
// ─── Helper builders ──────────────────────────────────────────────────────────
|
|
90
125
|
/** Creates a Title section */
|
|
91
126
|
function title(text, styles) {
|
|
@@ -230,4 +265,4 @@ async function test_thermal_printer(testPrintRequest) {
|
|
|
230
265
|
});
|
|
231
266
|
}
|
|
232
267
|
|
|
233
|
-
export { BARCODE_TEXT_POSITION, BARCODE_TYPE,
|
|
268
|
+
export { BARCODE_TEXT_POSITION, BARCODE_TYPE, CUT_MODE, DEFAULT_PAPER_SIZE, ENCODE, IMAGE_MODE, PAPER_SIZE_CHARS_PER_LINE, PAPER_SIZE_PIXELS_WIDTH, QR_ERROR_CORRECTION, TEXT_ALIGN, TEXT_FONT, TEXT_SIZE, barcode, beep, cut, dataMatrix, drawer, feed, getPaperSizeCharsPerLine, getPaperSizePixelsWidth, globalStyles, image, line, list_thermal_printers, logo, pdf417, print_thermal_printer, qr, subtitle, table, test_thermal_printer, text, title };
|