@thermal-print/escpos 0.2.0 → 0.3.1-beta.0
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/dist/command-adapters/escbematech-adapter.d.ts +1 -1
- package/dist/command-adapters/escbematech-adapter.d.ts.map +1 -1
- package/dist/command-adapters/escbematech-adapter.js +3 -40
- package/dist/command-adapters/escpos-adapter.d.ts +1 -1
- package/dist/command-adapters/escpos-adapter.d.ts.map +1 -1
- package/dist/command-adapters/escpos-adapter.js +5 -42
- package/dist/command-adapters/index.d.ts +1 -1
- package/dist/command-adapters/index.d.ts.map +1 -1
- package/dist/command-adapters/index.js +2 -7
- package/dist/command-adapters/types.d.ts +2 -1
- package/dist/command-adapters/types.d.ts.map +1 -1
- package/dist/command-adapters/types.js +1 -2
- package/dist/commands/escbematech.js +217 -306
- package/dist/commands/escpos.d.ts +2 -1
- package/dist/commands/escpos.d.ts.map +1 -1
- package/dist/commands/escpos.js +195 -268
- package/dist/converter.js +10 -13
- package/dist/encodings/cp860.js +3 -8
- package/dist/generator.d.ts +11 -5
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js +50 -64
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -44
- package/dist/styles.d.ts +14 -19
- package/dist/styles.d.ts.map +1 -1
- package/dist/styles.js +32 -52
- package/dist/traverser.d.ts.map +1 -1
- package/dist/traverser.js +55 -32
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -2
- package/package.json +18 -9
- package/LICENSE +0 -21
package/dist/commands/escpos.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* ESC/POS Command Set
|
|
4
3
|
*
|
|
@@ -8,57 +7,51 @@
|
|
|
8
7
|
* This file contains all documented ESC/POS commands organized by category.
|
|
9
8
|
* Commands are compatible with standard ESC/POS thermal printers.
|
|
10
9
|
*/
|
|
11
|
-
|
|
12
|
-
exports.UNDERLINE_2DOT = exports.UNDERLINE_1DOT = exports.UPSIDE_DOWN_OFF = exports.UPSIDE_DOWN_ON = exports.ROTATE_90_OFF = exports.ROTATE_90_ON = exports.SELECT_FONT_D = exports.selectFont = exports.CharacterFont = exports.DOUBLE_STRIKE_OFF = exports.DOUBLE_STRIKE_ON = exports.CLEAR_TABS = exports.setTabPositions = exports.setCharacterSpacing = exports.setRelativePosition = exports.setAbsolutePosition = exports.realtimePulse = exports.realtimeRequest = exports.transmitRealtimeStatus = exports.encodeText = exports.generateRasterImage = exports.generateQRCode = exports.CODEPAGE_WPC1252 = exports.CODEPAGE_CP860 = exports.CODEPAGE_CP437 = exports.cutWithFeed = exports.CUT_PARTIAL = exports.CUT_FULL = exports.feedLines = exports.LINE_FEED = exports.LINE_SPACING_DEFAULT = exports.setLineSpacing = exports.calculateCharacterSize = exports.UNDERLINE_OFF = exports.UNDERLINE_ON = exports.BOLD_OFF = exports.BOLD_ON = exports.ALIGN_RIGHT = exports.ALIGN_CENTER = exports.ALIGN_LEFT = exports.INIT = exports.GS = exports.FS = exports.ESC = exports.CAN = exports.DLE = exports.CR = exports.FF = exports.LF = exports.HT = void 0;
|
|
13
|
-
exports.selectCharacterSize = exports.generatePDF417 = exports.printPDF417 = exports.storePDF417Data = exports.setPDF417ErrorCorrection = exports.setPDF417RowHeight = exports.setPDF417Width = exports.setPDF417Rows = exports.setPDF417Columns = exports.printBarcodeCODE128 = exports.printBarcodeCODE93 = exports.printBarcodeCODABAR = exports.printBarcodeITF = exports.printBarcodeCODE39 = exports.printBarcodeEAN8 = exports.printBarcodeEAN13 = exports.printBarcodeUPCE = exports.printBarcodeUPCA = exports.printBarcodeWithLength = exports.printBarcode = exports.BarcodeType = exports.setBarcodeWidth = exports.setBarcodeHeight = exports.setBarcodeFont = exports.setBarcodeHRI = exports.BarcodeHRIPosition = exports.defineNVBitImage = exports.printNVBitImage = exports.printDownloadedBitImage = exports.DownloadedImageMode = exports.defineDownloadedBitImage = exports.printBitImage = exports.BitImageMode = exports.setCodePage = exports.CodePage = exports.selectInternationalCharset = exports.InternationalCharset = exports.disablePanelButtons = exports.enablePanelButtons = exports.selectPaperSensorStop = exports.selectPaperSensorOutput = exports.generatePulse = exports.selectPeripheral = exports.cutAndFeedPartial = exports.cutAndFeedFull = exports.CUT_PARTIAL_ESC = exports.CUT_FULL_ESC = exports.printAndReverseFeed = exports.printAndFeed = exports.LINE_SPACING_DEFAULT_ALT = void 0;
|
|
14
|
-
exports.executeTestPrint = exports.CANCEL = exports.UNIDIRECTIONAL_OFF = exports.UNIDIRECTIONAL_ON = exports.executeMacro = exports.END_MACRO = exports.START_MACRO = exports.setPrintingAreaWidth = exports.setLeftMargin = exports.requestStatus = exports.StatusType = exports.requestPrinterID = exports.PrinterIDType = exports.disableASB = exports.enableASB = exports.setCharacterSmoothing = exports.setCharacterColor = exports.REVERSE_PRINT_OFF = exports.REVERSE_PRINT_ON = void 0;
|
|
15
|
-
const cp860_1 = require("../encodings/cp860");
|
|
10
|
+
import { encodeCP860 } from "../encodings/cp860";
|
|
16
11
|
// ============================================================================
|
|
17
12
|
// CONTROL CHARACTERS
|
|
18
13
|
// ============================================================================
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
export const HT = 0x09; // Horizontal Tab
|
|
15
|
+
export const LF = 0x0a; // Line Feed
|
|
16
|
+
export const FF = 0x0c; // Form Feed
|
|
17
|
+
export const CR = 0x0d; // Carriage Return
|
|
18
|
+
export const DLE = 0x10; // Data Link Escape
|
|
19
|
+
export const CAN = 0x18; // Cancel
|
|
20
|
+
export const ESC = 0x1b; // Escape
|
|
21
|
+
export const FS = 0x1c; // File Separator
|
|
22
|
+
export const GS = 0x1d; // Group Separator
|
|
28
23
|
// Initialize printer
|
|
29
24
|
// ESC @ - Reset printer to default state
|
|
30
|
-
|
|
25
|
+
export const INIT = [ESC, 0x40];
|
|
31
26
|
// Text alignment
|
|
32
27
|
// ESC a n - Set text alignment (n: 0=left, 1=center, 2=right)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
export const ALIGN_LEFT = [ESC, 0x61, 0x00];
|
|
29
|
+
export const ALIGN_CENTER = [ESC, 0x61, 0x01];
|
|
30
|
+
export const ALIGN_RIGHT = [ESC, 0x61, 0x02];
|
|
36
31
|
// Text emphasis
|
|
37
32
|
// ESC E n - Turn bold on/off (n: 0=off, 1=on)
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
export const BOLD_ON = [ESC, 0x45, 0x01];
|
|
34
|
+
export const BOLD_OFF = [ESC, 0x45, 0x00];
|
|
40
35
|
// ESC - n - Turn underline on/off (n: 0=off, 1=on, 2=double)
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
export const UNDERLINE_ON = [ESC, 0x2d, 0x01];
|
|
37
|
+
export const UNDERLINE_OFF = [ESC, 0x2d, 0x00];
|
|
43
38
|
/**
|
|
44
39
|
* Calculate character size using ESC ! command (compatible with more printers)
|
|
45
40
|
* ESC ! only supports up to 2x2 character size
|
|
46
41
|
* @param width - Width multiplier (1 or 2)
|
|
47
42
|
* @param height - Height multiplier (1 or 2)
|
|
48
43
|
* @param bold - Whether text should be bold (optional, default: false)
|
|
44
|
+
* @param font - Font selection: 0 = Font A (12x24), 1 = Font B (9x17) (optional, default: 0)
|
|
49
45
|
* @returns ESC/POS ESC ! n command bytes
|
|
50
46
|
*/
|
|
51
|
-
const calculateCharacterSize = (width, height, bold = false) => {
|
|
47
|
+
export const calculateCharacterSize = (width, height, bold = false, font = 0) => {
|
|
52
48
|
// ESC ! command format:
|
|
53
49
|
// Bit 0: Character font (0=Font A, 1=Font B)
|
|
54
50
|
// Bit 3: Emphasis (bold)
|
|
55
51
|
// Bit 4: Double-height
|
|
56
52
|
// Bit 5: Double-width
|
|
57
53
|
// Bit 7: Underline
|
|
58
|
-
|
|
59
|
-
// Note: Font D (16×24 dots) is selected separately via ESC U command
|
|
60
|
-
// and will override this font selection
|
|
61
|
-
let n = 0x01; // Font B
|
|
54
|
+
let n = font & 0x01; // Bit 0: font selection
|
|
62
55
|
// Set double-height bit (bit 4 = 0x10)
|
|
63
56
|
if (height >= 2) {
|
|
64
57
|
n |= 0x10;
|
|
@@ -71,38 +64,34 @@ const calculateCharacterSize = (width, height, bold = false) => {
|
|
|
71
64
|
if (bold) {
|
|
72
65
|
n |= 0x08;
|
|
73
66
|
}
|
|
74
|
-
return [
|
|
67
|
+
return [ESC, 0x21, n];
|
|
75
68
|
};
|
|
76
|
-
exports.calculateCharacterSize = calculateCharacterSize;
|
|
77
69
|
// Line spacing
|
|
78
70
|
// ESC 3 n - Set line spacing to n dots
|
|
79
71
|
// Note: Using minimum of 18 dots for consistency with ESC/Bematech protocol
|
|
80
|
-
const setLineSpacing = (dots) => {
|
|
72
|
+
export const setLineSpacing = (dots) => {
|
|
81
73
|
const value = Math.max(18, Math.min(255, dots));
|
|
82
|
-
return [
|
|
74
|
+
return [ESC, 0x33, value];
|
|
83
75
|
};
|
|
84
|
-
exports.setLineSpacing = setLineSpacing;
|
|
85
76
|
// Default line spacing (30 dots = ~3.75mm)
|
|
86
|
-
|
|
77
|
+
export const LINE_SPACING_DEFAULT = [ESC, 0x33, 30];
|
|
87
78
|
// Paper control
|
|
88
79
|
// LF - Line feed (move paper up one line)
|
|
89
|
-
|
|
80
|
+
export const LINE_FEED = [LF];
|
|
90
81
|
// ESC d n - Print and feed n lines
|
|
91
|
-
const feedLines = (lines) => [
|
|
92
|
-
exports.feedLines = feedLines;
|
|
82
|
+
export const feedLines = (lines) => [ESC, 0x64, lines];
|
|
93
83
|
// GS V m - Paper cut
|
|
94
84
|
// m: 0=full cut, 1=partial cut
|
|
95
|
-
|
|
96
|
-
|
|
85
|
+
export const CUT_FULL = [GS, 0x56, 0x00];
|
|
86
|
+
export const CUT_PARTIAL = [GS, 0x56, 0x01];
|
|
97
87
|
// Alternative: GS V m n - Cut with feed
|
|
98
|
-
const cutWithFeed = (lines) => [
|
|
99
|
-
exports.cutWithFeed = cutWithFeed;
|
|
88
|
+
export const cutWithFeed = (lines) => [GS, 0x56, 0x41, lines];
|
|
100
89
|
// Character code table
|
|
101
90
|
// ESC t n - Select character code table
|
|
102
91
|
// Common tables: 0=CP437, 3=CP860 (Portuguese), 16=WPC1252
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
92
|
+
export const CODEPAGE_CP437 = [ESC, 0x74, 0x00]; // USA
|
|
93
|
+
export const CODEPAGE_CP860 = [ESC, 0x74, 0x03]; // Portuguese
|
|
94
|
+
export const CODEPAGE_WPC1252 = [ESC, 0x74, 0x10]; // Windows Latin-1
|
|
106
95
|
// Barcode and QR Code
|
|
107
96
|
// QR Code: GS ( k pL pH cn fn n1 n2 [data]
|
|
108
97
|
// This is a complex command, implemented as a function
|
|
@@ -112,27 +101,26 @@ exports.CODEPAGE_WPC1252 = [exports.ESC, 0x74, 0x10]; // Windows Latin-1
|
|
|
112
101
|
* @param size - QR code module size (1-16, default 6)
|
|
113
102
|
* @returns ESC/POS command bytes
|
|
114
103
|
*/
|
|
115
|
-
const generateQRCode = (data, size = 6) => {
|
|
104
|
+
export const generateQRCode = (data, size = 6) => {
|
|
116
105
|
const commands = [];
|
|
117
106
|
// QR Code model (function 165, cn=49, fn=65, n=48/49/50)
|
|
118
107
|
// Model 2 (most common)
|
|
119
|
-
commands.push(
|
|
108
|
+
commands.push(GS, 0x28, 0x6b, 0x04, 0x00, 0x31, 0x41, 0x32, 0x00);
|
|
120
109
|
// QR Code size (function 167, cn=49, fn=67, n=size)
|
|
121
|
-
commands.push(
|
|
110
|
+
commands.push(GS, 0x28, 0x6b, 0x03, 0x00, 0x31, 0x43, size);
|
|
122
111
|
// QR Code error correction (function 169, cn=49, fn=69, n=48-51)
|
|
123
112
|
// 48=L(7%), 49=M(15%), 50=Q(25%), 51=H(30%)
|
|
124
|
-
commands.push(
|
|
113
|
+
commands.push(GS, 0x28, 0x6b, 0x03, 0x00, 0x31, 0x45, 0x31);
|
|
125
114
|
// Store QR code data (function 180, cn=49, fn=80)
|
|
126
115
|
const dataBytes = new TextEncoder().encode(data);
|
|
127
116
|
const pL = (dataBytes.length + 3) % 256;
|
|
128
117
|
const pH = Math.floor((dataBytes.length + 3) / 256);
|
|
129
|
-
commands.push(
|
|
118
|
+
commands.push(GS, 0x28, 0x6b, pL, pH, 0x31, 0x50, 0x30);
|
|
130
119
|
commands.push(...Array.from(dataBytes));
|
|
131
120
|
// Print QR code (function 181, cn=49, fn=81)
|
|
132
|
-
commands.push(
|
|
121
|
+
commands.push(GS, 0x28, 0x6b, 0x03, 0x00, 0x31, 0x51, 0x30);
|
|
133
122
|
return commands;
|
|
134
123
|
};
|
|
135
|
-
exports.generateQRCode = generateQRCode;
|
|
136
124
|
/**
|
|
137
125
|
* Generate raster image command (GS v 0)
|
|
138
126
|
* @param imageData - Monochrome bitmap data (1 bit per pixel, 1=black, 0=white)
|
|
@@ -140,7 +128,7 @@ exports.generateQRCode = generateQRCode;
|
|
|
140
128
|
* @param height - Image height in pixels
|
|
141
129
|
* @returns ESC/POS command bytes
|
|
142
130
|
*/
|
|
143
|
-
const generateRasterImage = (imageData, width, height) => {
|
|
131
|
+
export const generateRasterImage = (imageData, width, height) => {
|
|
144
132
|
const commands = [];
|
|
145
133
|
// Calculate bytes per line (width in bytes, rounded up to nearest byte)
|
|
146
134
|
const bytesPerLine = Math.ceil(width / 8);
|
|
@@ -149,7 +137,7 @@ const generateRasterImage = (imageData, width, height) => {
|
|
|
149
137
|
// xL xH = width in bytes (little endian)
|
|
150
138
|
// yL yH = height in dots (little endian)
|
|
151
139
|
// d1...dk = raster image data
|
|
152
|
-
commands.push(
|
|
140
|
+
commands.push(GS, 0x76, 0x30, 0x00); // GS v 0 m (m=0: normal)
|
|
153
141
|
// Width in bytes (little endian)
|
|
154
142
|
commands.push(bytesPerLine & 0xff);
|
|
155
143
|
commands.push((bytesPerLine >> 8) & 0xff);
|
|
@@ -160,17 +148,15 @@ const generateRasterImage = (imageData, width, height) => {
|
|
|
160
148
|
commands.push(...imageData);
|
|
161
149
|
return commands;
|
|
162
150
|
};
|
|
163
|
-
exports.generateRasterImage = generateRasterImage;
|
|
164
151
|
/**
|
|
165
152
|
* Text encoding helper
|
|
166
153
|
* Converts string to CP860 byte array for Brazilian Portuguese thermal printers
|
|
167
154
|
*/
|
|
168
|
-
const encodeText = (text) => {
|
|
155
|
+
export const encodeText = (text) => {
|
|
169
156
|
// CP860 is the standard codepage for Portuguese thermal printers
|
|
170
157
|
// Supports: ç Ç á é í ó ú à ã õ â ê ô and other Portuguese characters
|
|
171
|
-
return
|
|
158
|
+
return encodeCP860(text);
|
|
172
159
|
};
|
|
173
|
-
exports.encodeText = encodeText;
|
|
174
160
|
// ============================================================================
|
|
175
161
|
// REAL-TIME COMMANDS
|
|
176
162
|
// ============================================================================
|
|
@@ -181,33 +167,30 @@ exports.encodeText = encodeText;
|
|
|
181
167
|
* n = 3: Transmit error status
|
|
182
168
|
* n = 4: Transmit paper roll sensor status
|
|
183
169
|
*/
|
|
184
|
-
const transmitRealtimeStatus = (n) => [
|
|
185
|
-
|
|
170
|
+
export const transmitRealtimeStatus = (n) => [
|
|
171
|
+
DLE,
|
|
186
172
|
0x04,
|
|
187
173
|
n,
|
|
188
174
|
];
|
|
189
|
-
exports.transmitRealtimeStatus = transmitRealtimeStatus;
|
|
190
175
|
/**
|
|
191
176
|
* DLE ENQ n - Real-time request to printer
|
|
192
177
|
* n = 1: Recover from error and restart printing
|
|
193
178
|
* n = 2: Clear buffer
|
|
194
179
|
*/
|
|
195
|
-
const realtimeRequest = (n) => [
|
|
196
|
-
exports.realtimeRequest = realtimeRequest;
|
|
180
|
+
export const realtimeRequest = (n) => [DLE, 0x05, n];
|
|
197
181
|
/**
|
|
198
182
|
* DLE DC4 fn a b - Generate pulse in real-time
|
|
199
183
|
* fn = 1: Generate pulse
|
|
200
184
|
* a = drawer (0 or 1)
|
|
201
185
|
* b = pulse time
|
|
202
186
|
*/
|
|
203
|
-
const realtimePulse = (drawer, pulseTime) => [
|
|
204
|
-
|
|
187
|
+
export const realtimePulse = (drawer, pulseTime) => [
|
|
188
|
+
DLE,
|
|
205
189
|
0x14,
|
|
206
190
|
0x01,
|
|
207
191
|
drawer,
|
|
208
192
|
pulseTime,
|
|
209
193
|
];
|
|
210
|
-
exports.realtimePulse = realtimePulse;
|
|
211
194
|
// ============================================================================
|
|
212
195
|
// TEXT POSITION & LAYOUT
|
|
213
196
|
// ============================================================================
|
|
@@ -215,51 +198,47 @@ exports.realtimePulse = realtimePulse;
|
|
|
215
198
|
* ESC $ nL nH - Set absolute print position
|
|
216
199
|
* Position = ((nH × 256) + nL) × (horizontal motion unit)
|
|
217
200
|
*/
|
|
218
|
-
const setAbsolutePosition = (position) => {
|
|
201
|
+
export const setAbsolutePosition = (position) => {
|
|
219
202
|
const nL = position & 0xff;
|
|
220
203
|
const nH = (position >> 8) & 0xff;
|
|
221
|
-
return [
|
|
204
|
+
return [ESC, 0x24, nL, nH];
|
|
222
205
|
};
|
|
223
|
-
exports.setAbsolutePosition = setAbsolutePosition;
|
|
224
206
|
/**
|
|
225
207
|
* ESC \ nL nH - Set relative print position
|
|
226
208
|
* Relative position = ((nH × 256) + nL) × (horizontal motion unit)
|
|
227
209
|
* Supports negative values (two's complement)
|
|
228
210
|
*/
|
|
229
|
-
const setRelativePosition = (position) => {
|
|
211
|
+
export const setRelativePosition = (position) => {
|
|
230
212
|
const nL = position & 0xff;
|
|
231
213
|
const nH = (position >> 8) & 0xff;
|
|
232
|
-
return [
|
|
214
|
+
return [ESC, 0x5c, nL, nH];
|
|
233
215
|
};
|
|
234
|
-
exports.setRelativePosition = setRelativePosition;
|
|
235
216
|
/**
|
|
236
217
|
* ESC SP n - Set right-side character spacing
|
|
237
218
|
* Range: 0 ≤ n ≤ 255
|
|
238
219
|
* Spacing = n × (horizontal motion unit)
|
|
239
220
|
*/
|
|
240
|
-
const setCharacterSpacing = (dots) => [
|
|
241
|
-
|
|
221
|
+
export const setCharacterSpacing = (dots) => [
|
|
222
|
+
ESC,
|
|
242
223
|
0x20,
|
|
243
224
|
Math.max(0, Math.min(255, dots)),
|
|
244
225
|
];
|
|
245
|
-
exports.setCharacterSpacing = setCharacterSpacing;
|
|
246
226
|
/**
|
|
247
227
|
* ESC D n1...nk NUL - Set horizontal tab positions
|
|
248
228
|
* n1-nk: Tab positions (1-255), up to 32 positions
|
|
249
229
|
* Must be in ascending order, terminated with NUL
|
|
250
230
|
*/
|
|
251
|
-
const setTabPositions = (positions) => {
|
|
231
|
+
export const setTabPositions = (positions) => {
|
|
252
232
|
const validPositions = positions
|
|
253
233
|
.filter((p) => p >= 1 && p <= 255)
|
|
254
234
|
.slice(0, 32)
|
|
255
235
|
.sort((a, b) => a - b);
|
|
256
|
-
return [
|
|
236
|
+
return [ESC, 0x44, ...validPositions, 0x00];
|
|
257
237
|
};
|
|
258
|
-
exports.setTabPositions = setTabPositions;
|
|
259
238
|
/**
|
|
260
239
|
* ESC D NUL - Cancel all horizontal tab positions
|
|
261
240
|
*/
|
|
262
|
-
|
|
241
|
+
export const CLEAR_TABS = [ESC, 0x44, 0x00];
|
|
263
242
|
// ============================================================================
|
|
264
243
|
// TEXT EMPHASIS & STYLES
|
|
265
244
|
// ============================================================================
|
|
@@ -268,53 +247,52 @@ exports.CLEAR_TABS = [exports.ESC, 0x44, 0x00];
|
|
|
268
247
|
* n = 0 or 48: Turn off double-strike mode
|
|
269
248
|
* n = 1 or 49: Turn on double-strike mode
|
|
270
249
|
*/
|
|
271
|
-
|
|
272
|
-
|
|
250
|
+
export const DOUBLE_STRIKE_ON = [ESC, 0x47, 0x01];
|
|
251
|
+
export const DOUBLE_STRIKE_OFF = [ESC, 0x47, 0x00];
|
|
273
252
|
/**
|
|
274
253
|
* Character font selection
|
|
275
254
|
*/
|
|
276
|
-
var CharacterFont;
|
|
255
|
+
export var CharacterFont;
|
|
277
256
|
(function (CharacterFont) {
|
|
278
257
|
CharacterFont[CharacterFont["FONT_A"] = 0] = "FONT_A";
|
|
279
258
|
CharacterFont[CharacterFont["FONT_B"] = 1] = "FONT_B";
|
|
280
259
|
CharacterFont[CharacterFont["FONT_C"] = 2] = "FONT_C";
|
|
281
|
-
})(CharacterFont || (
|
|
260
|
+
})(CharacterFont || (CharacterFont = {}));
|
|
282
261
|
/**
|
|
283
262
|
* ESC M n - Select character font
|
|
284
263
|
* n = 0 or 48: Font A (12×24)
|
|
285
264
|
* n = 1 or 49: Font B (9×17)
|
|
286
265
|
* n = 2 or 50: Font C (printer dependent)
|
|
287
266
|
*/
|
|
288
|
-
const selectFont = (font) => [
|
|
289
|
-
exports.selectFont = selectFont;
|
|
267
|
+
export const selectFont = (font) => [ESC, 0x4d, font];
|
|
290
268
|
/**
|
|
291
269
|
* ESC U - Select Font D (Phoenix printers only)
|
|
292
270
|
* Font D: 16×24 dots
|
|
293
271
|
* Warning: This is a Phoenix-specific feature and may not work on all printers
|
|
294
272
|
*/
|
|
295
|
-
|
|
273
|
+
export const SELECT_FONT_D = [ESC, 0x51];
|
|
296
274
|
/**
|
|
297
275
|
* ESC V n - Turn 90° clockwise rotation mode on/off
|
|
298
276
|
* n = 0 or 48: Turn off 90° clockwise rotation mode
|
|
299
277
|
* n = 1 or 49: Turn on 90° clockwise rotation mode
|
|
300
278
|
*/
|
|
301
|
-
|
|
302
|
-
|
|
279
|
+
export const ROTATE_90_ON = [ESC, 0x56, 0x01];
|
|
280
|
+
export const ROTATE_90_OFF = [ESC, 0x56, 0x00];
|
|
303
281
|
/**
|
|
304
282
|
* ESC { n - Turn upside-down printing mode on/off
|
|
305
283
|
* n = 0 or 48: Turn off upside-down printing mode
|
|
306
284
|
* n = 1 or 49: Turn on upside-down printing mode
|
|
307
285
|
*/
|
|
308
|
-
|
|
309
|
-
|
|
286
|
+
export const UPSIDE_DOWN_ON = [ESC, 0x7b, 0x01];
|
|
287
|
+
export const UPSIDE_DOWN_OFF = [ESC, 0x7b, 0x00];
|
|
310
288
|
/**
|
|
311
289
|
* ESC - n - Turn underline mode on/off with thickness selection
|
|
312
290
|
* n = 0 or 48: Turn off underline mode
|
|
313
291
|
* n = 1 or 49: Turn on underline mode (1-dot thick)
|
|
314
292
|
* n = 2 or 50: Turn on underline mode (2-dots thick)
|
|
315
293
|
*/
|
|
316
|
-
|
|
317
|
-
|
|
294
|
+
export const UNDERLINE_1DOT = [ESC, 0x2d, 0x01];
|
|
295
|
+
export const UNDERLINE_2DOT = [ESC, 0x2d, 0x02];
|
|
318
296
|
// ============================================================================
|
|
319
297
|
// LINE SPACING & PAPER CONTROL (ADDITIONAL)
|
|
320
298
|
// ============================================================================
|
|
@@ -322,29 +300,27 @@ exports.UNDERLINE_2DOT = [exports.ESC, 0x2d, 0x02];
|
|
|
322
300
|
* ESC 2 - Select default line spacing
|
|
323
301
|
* Sets line spacing to approximately 4.23mm (1/6 inch)
|
|
324
302
|
*/
|
|
325
|
-
|
|
303
|
+
export const LINE_SPACING_DEFAULT_ALT = [ESC, 0x32, 0x5];
|
|
326
304
|
/**
|
|
327
305
|
* ESC J n - Print and feed paper
|
|
328
306
|
* Range: 0 ≤ n ≤ 255
|
|
329
307
|
* Feed amount = n × (vertical motion unit)
|
|
330
308
|
*/
|
|
331
|
-
const printAndFeed = (dots) => [
|
|
332
|
-
|
|
309
|
+
export const printAndFeed = (dots) => [
|
|
310
|
+
ESC,
|
|
333
311
|
0x4a,
|
|
334
312
|
Math.max(0, Math.min(255, dots)),
|
|
335
313
|
];
|
|
336
|
-
exports.printAndFeed = printAndFeed;
|
|
337
314
|
/**
|
|
338
315
|
* ESC K n - Print and reverse feed
|
|
339
316
|
* Range: 0 ≤ n ≤ 255
|
|
340
317
|
* Reverse feed amount = n × (vertical motion unit)
|
|
341
318
|
*/
|
|
342
|
-
const printAndReverseFeed = (dots) => [
|
|
343
|
-
|
|
319
|
+
export const printAndReverseFeed = (dots) => [
|
|
320
|
+
ESC,
|
|
344
321
|
0x4b,
|
|
345
322
|
Math.max(0, Math.min(255, dots)),
|
|
346
323
|
];
|
|
347
|
-
exports.printAndReverseFeed = printAndReverseFeed;
|
|
348
324
|
// ============================================================================
|
|
349
325
|
// PAPER CUTTING (ADDITIONAL)
|
|
350
326
|
// ============================================================================
|
|
@@ -352,32 +328,30 @@ exports.printAndReverseFeed = printAndReverseFeed;
|
|
|
352
328
|
* ESC i - Full cut
|
|
353
329
|
* Executes a full cut (cuts paper completely)
|
|
354
330
|
*/
|
|
355
|
-
|
|
331
|
+
export const CUT_FULL_ESC = [ESC, 0x69];
|
|
356
332
|
/**
|
|
357
333
|
* ESC m - Partial cut
|
|
358
334
|
* Executes a partial cut (leaves connection point)
|
|
359
335
|
*/
|
|
360
|
-
|
|
336
|
+
export const CUT_PARTIAL_ESC = [ESC, 0x6d];
|
|
361
337
|
/**
|
|
362
338
|
* GS V m n - Cut paper and feed
|
|
363
339
|
* m = 65 (0x41): Feed then full cut
|
|
364
340
|
* m = 66 (0x42): Feed then partial cut
|
|
365
341
|
* n = feed amount before cut
|
|
366
342
|
*/
|
|
367
|
-
const cutAndFeedFull = (dots) => [
|
|
368
|
-
|
|
343
|
+
export const cutAndFeedFull = (dots) => [
|
|
344
|
+
GS,
|
|
369
345
|
0x56,
|
|
370
346
|
0x41,
|
|
371
347
|
Math.max(0, Math.min(255, dots)),
|
|
372
348
|
];
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
exports.GS,
|
|
349
|
+
export const cutAndFeedPartial = (dots) => [
|
|
350
|
+
GS,
|
|
376
351
|
0x56,
|
|
377
352
|
0x42,
|
|
378
353
|
Math.max(0, Math.min(255, dots)),
|
|
379
354
|
];
|
|
380
|
-
exports.cutAndFeedPartial = cutAndFeedPartial;
|
|
381
355
|
// ============================================================================
|
|
382
356
|
// PERIPHERAL DEVICE CONTROL
|
|
383
357
|
// ============================================================================
|
|
@@ -386,12 +360,11 @@ exports.cutAndFeedPartial = cutAndFeedPartial;
|
|
|
386
360
|
* n = 0: Disabled
|
|
387
361
|
* n = 1: Enabled
|
|
388
362
|
*/
|
|
389
|
-
const selectPeripheral = (enabled) => [
|
|
390
|
-
|
|
363
|
+
export const selectPeripheral = (enabled) => [
|
|
364
|
+
ESC,
|
|
391
365
|
0x3d,
|
|
392
366
|
enabled ? 0x01 : 0x00,
|
|
393
367
|
];
|
|
394
|
-
exports.selectPeripheral = selectPeripheral;
|
|
395
368
|
/**
|
|
396
369
|
* ESC p m t1 t2 - Generate pulse
|
|
397
370
|
* m = 0 or 48: Drawer kick-out connector pin 2
|
|
@@ -399,52 +372,47 @@ exports.selectPeripheral = selectPeripheral;
|
|
|
399
372
|
* t1 = ON time (0-255, units of 100ms)
|
|
400
373
|
* t2 = OFF time (0-255, units of 100ms)
|
|
401
374
|
*/
|
|
402
|
-
const generatePulse = (connector, onTime, offTime) => [
|
|
403
|
-
|
|
375
|
+
export const generatePulse = (connector, onTime, offTime) => [
|
|
376
|
+
ESC,
|
|
404
377
|
0x70,
|
|
405
378
|
connector,
|
|
406
379
|
Math.max(0, Math.min(255, onTime)),
|
|
407
380
|
Math.max(0, Math.min(255, offTime)),
|
|
408
381
|
];
|
|
409
|
-
exports.generatePulse = generatePulse;
|
|
410
382
|
/**
|
|
411
383
|
* ESC c 3 n - Select paper sensor(s) to output paper-end signals
|
|
412
384
|
* n is a bitmask for sensor selection
|
|
413
385
|
*/
|
|
414
|
-
const selectPaperSensorOutput = (sensorMask) => [
|
|
415
|
-
|
|
386
|
+
export const selectPaperSensorOutput = (sensorMask) => [
|
|
387
|
+
ESC,
|
|
416
388
|
0x63,
|
|
417
389
|
0x33,
|
|
418
390
|
sensorMask,
|
|
419
391
|
];
|
|
420
|
-
exports.selectPaperSensorOutput = selectPaperSensorOutput;
|
|
421
392
|
/**
|
|
422
393
|
* ESC c 4 n - Select paper sensor(s) to stop printing
|
|
423
394
|
* n is a bitmask for sensor selection
|
|
424
395
|
*/
|
|
425
|
-
const selectPaperSensorStop = (sensorMask) => [
|
|
426
|
-
|
|
396
|
+
export const selectPaperSensorStop = (sensorMask) => [
|
|
397
|
+
ESC,
|
|
427
398
|
0x63,
|
|
428
399
|
0x34,
|
|
429
400
|
sensorMask,
|
|
430
401
|
];
|
|
431
|
-
exports.selectPaperSensorStop = selectPaperSensorStop;
|
|
432
402
|
/**
|
|
433
403
|
* ESC c 5 n - Enable/disable panel buttons
|
|
434
404
|
* n = 0: Enable panel buttons
|
|
435
405
|
* n = 1: Disable panel buttons
|
|
436
406
|
*/
|
|
437
|
-
const enablePanelButtons = () => [
|
|
438
|
-
|
|
439
|
-
const disablePanelButtons = () => [exports.ESC, 0x63, 0x35, 0x01];
|
|
440
|
-
exports.disablePanelButtons = disablePanelButtons;
|
|
407
|
+
export const enablePanelButtons = () => [ESC, 0x63, 0x35, 0x00];
|
|
408
|
+
export const disablePanelButtons = () => [ESC, 0x63, 0x35, 0x01];
|
|
441
409
|
// ============================================================================
|
|
442
410
|
// CHARACTER CODE TABLES
|
|
443
411
|
// ============================================================================
|
|
444
412
|
/**
|
|
445
413
|
* International character set selection
|
|
446
414
|
*/
|
|
447
|
-
var InternationalCharset;
|
|
415
|
+
export var InternationalCharset;
|
|
448
416
|
(function (InternationalCharset) {
|
|
449
417
|
InternationalCharset[InternationalCharset["USA"] = 0] = "USA";
|
|
450
418
|
InternationalCharset[InternationalCharset["FRANCE"] = 1] = "FRANCE";
|
|
@@ -460,16 +428,15 @@ var InternationalCharset;
|
|
|
460
428
|
InternationalCharset[InternationalCharset["SPAIN_II"] = 11] = "SPAIN_II";
|
|
461
429
|
InternationalCharset[InternationalCharset["LATIN_AMERICA"] = 12] = "LATIN_AMERICA";
|
|
462
430
|
InternationalCharset[InternationalCharset["KOREA"] = 13] = "KOREA";
|
|
463
|
-
})(InternationalCharset || (
|
|
431
|
+
})(InternationalCharset || (InternationalCharset = {}));
|
|
464
432
|
/**
|
|
465
433
|
* ESC R n - Select international character set
|
|
466
434
|
*/
|
|
467
|
-
const selectInternationalCharset = (charset) => [
|
|
468
|
-
exports.selectInternationalCharset = selectInternationalCharset;
|
|
435
|
+
export const selectInternationalCharset = (charset) => [ESC, 0x52, charset];
|
|
469
436
|
/**
|
|
470
437
|
* Extended code page enumeration
|
|
471
438
|
*/
|
|
472
|
-
var CodePage;
|
|
439
|
+
export var CodePage;
|
|
473
440
|
(function (CodePage) {
|
|
474
441
|
CodePage[CodePage["CP437"] = 0] = "CP437";
|
|
475
442
|
CodePage[CodePage["CP850"] = 2] = "CP850";
|
|
@@ -485,37 +452,35 @@ var CodePage;
|
|
|
485
452
|
CodePage[CodePage["CP852"] = 18] = "CP852";
|
|
486
453
|
CodePage[CodePage["CP858"] = 19] = "CP858";
|
|
487
454
|
CodePage[CodePage["WPC1252"] = 16] = "WPC1252";
|
|
488
|
-
})(CodePage || (
|
|
455
|
+
})(CodePage || (CodePage = {}));
|
|
489
456
|
/**
|
|
490
457
|
* ESC t n - Select character code table
|
|
491
458
|
*/
|
|
492
|
-
const setCodePage = (page) => [
|
|
493
|
-
exports.setCodePage = setCodePage;
|
|
459
|
+
export const setCodePage = (page) => [ESC, 0x74, page];
|
|
494
460
|
// ============================================================================
|
|
495
461
|
// GRAPHICS - BIT IMAGE
|
|
496
462
|
// ============================================================================
|
|
497
463
|
/**
|
|
498
464
|
* Bit image modes for ESC *
|
|
499
465
|
*/
|
|
500
|
-
var BitImageMode;
|
|
466
|
+
export var BitImageMode;
|
|
501
467
|
(function (BitImageMode) {
|
|
502
468
|
BitImageMode[BitImageMode["MODE_8_SINGLE"] = 0] = "MODE_8_SINGLE";
|
|
503
469
|
BitImageMode[BitImageMode["MODE_8_DOUBLE"] = 1] = "MODE_8_DOUBLE";
|
|
504
470
|
BitImageMode[BitImageMode["MODE_24_SINGLE"] = 32] = "MODE_24_SINGLE";
|
|
505
471
|
BitImageMode[BitImageMode["MODE_24_DOUBLE"] = 33] = "MODE_24_DOUBLE";
|
|
506
|
-
})(BitImageMode || (
|
|
472
|
+
})(BitImageMode || (BitImageMode = {}));
|
|
507
473
|
/**
|
|
508
474
|
* ESC * m nL nH d1...dk - Print bit image
|
|
509
475
|
* m: Bit image mode
|
|
510
476
|
* nL, nH: Number of data columns (nL + nH × 256)
|
|
511
477
|
* d1...dk: Bit image data
|
|
512
478
|
*/
|
|
513
|
-
const printBitImage = (mode, width, data) => {
|
|
479
|
+
export const printBitImage = (mode, width, data) => {
|
|
514
480
|
const nL = width & 0xff;
|
|
515
481
|
const nH = (width >> 8) & 0xff;
|
|
516
|
-
return [
|
|
482
|
+
return [ESC, 0x2a, mode, nL, nH, ...data];
|
|
517
483
|
};
|
|
518
|
-
exports.printBitImage = printBitImage;
|
|
519
484
|
// ============================================================================
|
|
520
485
|
// GRAPHICS - DOWNLOADED BIT IMAGE
|
|
521
486
|
// ============================================================================
|
|
@@ -526,28 +491,26 @@ exports.printBitImage = printBitImage;
|
|
|
526
491
|
* Horizontal dots = x × 8
|
|
527
492
|
* Vertical dots = y × 8
|
|
528
493
|
*/
|
|
529
|
-
const defineDownloadedBitImage = (x, y, data) => {
|
|
494
|
+
export const defineDownloadedBitImage = (x, y, data) => {
|
|
530
495
|
const xVal = Math.max(1, Math.min(255, x));
|
|
531
496
|
const yVal = Math.max(1, Math.min(48, y));
|
|
532
|
-
return [
|
|
497
|
+
return [GS, 0x2a, xVal, yVal, ...data];
|
|
533
498
|
};
|
|
534
|
-
exports.defineDownloadedBitImage = defineDownloadedBitImage;
|
|
535
499
|
/**
|
|
536
500
|
* Downloaded image print modes
|
|
537
501
|
*/
|
|
538
|
-
var DownloadedImageMode;
|
|
502
|
+
export var DownloadedImageMode;
|
|
539
503
|
(function (DownloadedImageMode) {
|
|
540
504
|
DownloadedImageMode[DownloadedImageMode["NORMAL"] = 0] = "NORMAL";
|
|
541
505
|
DownloadedImageMode[DownloadedImageMode["DOUBLE_WIDTH"] = 1] = "DOUBLE_WIDTH";
|
|
542
506
|
DownloadedImageMode[DownloadedImageMode["DOUBLE_HEIGHT"] = 2] = "DOUBLE_HEIGHT";
|
|
543
507
|
DownloadedImageMode[DownloadedImageMode["QUADRUPLE"] = 3] = "QUADRUPLE";
|
|
544
|
-
})(DownloadedImageMode || (
|
|
508
|
+
})(DownloadedImageMode || (DownloadedImageMode = {}));
|
|
545
509
|
/**
|
|
546
510
|
* GS / m - Print downloaded bit image
|
|
547
511
|
* m: Print mode (0-3)
|
|
548
512
|
*/
|
|
549
|
-
const printDownloadedBitImage = (mode) => [
|
|
550
|
-
exports.printDownloadedBitImage = printDownloadedBitImage;
|
|
513
|
+
export const printDownloadedBitImage = (mode) => [GS, 0x2f, mode];
|
|
551
514
|
// ============================================================================
|
|
552
515
|
// GRAPHICS - NV BIT IMAGE
|
|
553
516
|
// ============================================================================
|
|
@@ -556,8 +519,7 @@ exports.printDownloadedBitImage = printDownloadedBitImage;
|
|
|
556
519
|
* n: NV bit image number (1-255)
|
|
557
520
|
* m: Print mode (0-3, same as DownloadedImageMode)
|
|
558
521
|
*/
|
|
559
|
-
const printNVBitImage = (imageNumber, mode) => [
|
|
560
|
-
exports.printNVBitImage = printNVBitImage;
|
|
522
|
+
export const printNVBitImage = (imageNumber, mode) => [FS, 0x70, Math.max(1, Math.min(255, imageNumber)), mode];
|
|
561
523
|
/**
|
|
562
524
|
* FS q n [xL xH yL yH d1...dk]1...n - Define NV bit image
|
|
563
525
|
* n: Number of NV bit images to define (1-255)
|
|
@@ -566,8 +528,8 @@ exports.printNVBitImage = printNVBitImage;
|
|
|
566
528
|
* yL, yH: Height in bytes ((yH × 256 + yL) × 8 dots)
|
|
567
529
|
* d1...dk: Bit image data
|
|
568
530
|
*/
|
|
569
|
-
const defineNVBitImage = (images) => {
|
|
570
|
-
const result = [
|
|
531
|
+
export const defineNVBitImage = (images) => {
|
|
532
|
+
const result = [FS, 0x71, Math.min(images.length, 255)];
|
|
571
533
|
for (const img of images.slice(0, 255)) {
|
|
572
534
|
const xL = img.width & 0xff;
|
|
573
535
|
const xH = (img.width >> 8) & 0xff;
|
|
@@ -577,69 +539,64 @@ const defineNVBitImage = (images) => {
|
|
|
577
539
|
}
|
|
578
540
|
return result;
|
|
579
541
|
};
|
|
580
|
-
exports.defineNVBitImage = defineNVBitImage;
|
|
581
542
|
// ============================================================================
|
|
582
543
|
// BARCODE CONFIGURATION
|
|
583
544
|
// ============================================================================
|
|
584
545
|
/**
|
|
585
546
|
* Barcode HRI (Human Readable Interpretation) position
|
|
586
547
|
*/
|
|
587
|
-
var BarcodeHRIPosition;
|
|
548
|
+
export var BarcodeHRIPosition;
|
|
588
549
|
(function (BarcodeHRIPosition) {
|
|
589
550
|
BarcodeHRIPosition[BarcodeHRIPosition["NOT_PRINTED"] = 0] = "NOT_PRINTED";
|
|
590
551
|
BarcodeHRIPosition[BarcodeHRIPosition["ABOVE"] = 1] = "ABOVE";
|
|
591
552
|
BarcodeHRIPosition[BarcodeHRIPosition["BELOW"] = 2] = "BELOW";
|
|
592
553
|
BarcodeHRIPosition[BarcodeHRIPosition["BOTH"] = 3] = "BOTH";
|
|
593
|
-
})(BarcodeHRIPosition || (
|
|
554
|
+
})(BarcodeHRIPosition || (BarcodeHRIPosition = {}));
|
|
594
555
|
/**
|
|
595
556
|
* GS H n - Select HRI character print position
|
|
596
557
|
*/
|
|
597
|
-
const setBarcodeHRI = (position) => [
|
|
598
|
-
|
|
558
|
+
export const setBarcodeHRI = (position) => [
|
|
559
|
+
GS,
|
|
599
560
|
0x48,
|
|
600
561
|
position,
|
|
601
562
|
];
|
|
602
|
-
exports.setBarcodeHRI = setBarcodeHRI;
|
|
603
563
|
/**
|
|
604
564
|
* GS f n - Select font for HRI characters
|
|
605
565
|
* n = 0 or 48: Font A
|
|
606
566
|
* n = 1 or 49: Font B
|
|
607
567
|
*/
|
|
608
|
-
const setBarcodeFont = (fontB) => [
|
|
609
|
-
|
|
568
|
+
export const setBarcodeFont = (fontB) => [
|
|
569
|
+
GS,
|
|
610
570
|
0x66,
|
|
611
571
|
fontB ? 0x01 : 0x00,
|
|
612
572
|
];
|
|
613
|
-
exports.setBarcodeFont = setBarcodeFont;
|
|
614
573
|
/**
|
|
615
574
|
* GS h n - Set barcode height
|
|
616
575
|
* Range: 1 ≤ n ≤ 255 (in dots)
|
|
617
576
|
* Default: 162
|
|
618
577
|
*/
|
|
619
|
-
const setBarcodeHeight = (height) => [
|
|
620
|
-
|
|
578
|
+
export const setBarcodeHeight = (height) => [
|
|
579
|
+
GS,
|
|
621
580
|
0x68,
|
|
622
581
|
Math.max(1, Math.min(255, height)),
|
|
623
582
|
];
|
|
624
|
-
exports.setBarcodeHeight = setBarcodeHeight;
|
|
625
583
|
/**
|
|
626
584
|
* GS w n - Set barcode width
|
|
627
585
|
* Range: 2 ≤ n ≤ 6 (module width in dots)
|
|
628
586
|
* Default: 3
|
|
629
587
|
*/
|
|
630
|
-
const setBarcodeWidth = (width) => [
|
|
631
|
-
|
|
588
|
+
export const setBarcodeWidth = (width) => [
|
|
589
|
+
GS,
|
|
632
590
|
0x77,
|
|
633
591
|
Math.max(2, Math.min(6, width)),
|
|
634
592
|
];
|
|
635
|
-
exports.setBarcodeWidth = setBarcodeWidth;
|
|
636
593
|
// ============================================================================
|
|
637
594
|
// BARCODE PRINTING
|
|
638
595
|
// ============================================================================
|
|
639
596
|
/**
|
|
640
597
|
* Barcode symbologies
|
|
641
598
|
*/
|
|
642
|
-
var BarcodeType;
|
|
599
|
+
export var BarcodeType;
|
|
643
600
|
(function (BarcodeType) {
|
|
644
601
|
BarcodeType[BarcodeType["UPC_A"] = 0] = "UPC_A";
|
|
645
602
|
BarcodeType[BarcodeType["UPC_E"] = 1] = "UPC_E";
|
|
@@ -650,118 +607,107 @@ var BarcodeType;
|
|
|
650
607
|
BarcodeType[BarcodeType["CODABAR"] = 6] = "CODABAR";
|
|
651
608
|
BarcodeType[BarcodeType["CODE93"] = 72] = "CODE93";
|
|
652
609
|
BarcodeType[BarcodeType["CODE128"] = 73] = "CODE128";
|
|
653
|
-
})(BarcodeType || (
|
|
610
|
+
})(BarcodeType || (BarcodeType = {}));
|
|
654
611
|
/**
|
|
655
612
|
* GS k m d1...dk NUL - Print barcode (NUL-terminated)
|
|
656
613
|
* For barcode types 0-6 (UPC-A, UPC-E, EAN-13, EAN-8, CODE39, ITF, CODABAR)
|
|
657
614
|
*/
|
|
658
|
-
const printBarcode = (type, data) => {
|
|
615
|
+
export const printBarcode = (type, data) => {
|
|
659
616
|
const bytes = data.split("").map((c) => c.charCodeAt(0));
|
|
660
|
-
return [
|
|
617
|
+
return [GS, 0x6b, type, ...bytes, 0x00];
|
|
661
618
|
};
|
|
662
|
-
exports.printBarcode = printBarcode;
|
|
663
619
|
/**
|
|
664
620
|
* GS k m n d1...dn - Print barcode (length-specified)
|
|
665
621
|
* For barcode types 65-73 (with length prefix)
|
|
666
622
|
*/
|
|
667
|
-
const printBarcodeWithLength = (type, data) => {
|
|
623
|
+
export const printBarcodeWithLength = (type, data) => {
|
|
668
624
|
const bytes = data.split("").map((c) => c.charCodeAt(0));
|
|
669
|
-
return [
|
|
625
|
+
return [GS, 0x6b, type, bytes.length, ...bytes];
|
|
670
626
|
};
|
|
671
|
-
exports.printBarcodeWithLength = printBarcodeWithLength;
|
|
672
627
|
/**
|
|
673
628
|
* Print UPC-A barcode
|
|
674
629
|
* Requires 11-12 digits
|
|
675
630
|
*/
|
|
676
|
-
const printBarcodeUPCA = (data) => {
|
|
631
|
+
export const printBarcodeUPCA = (data) => {
|
|
677
632
|
if (!/^\d{11,12}$/.test(data)) {
|
|
678
633
|
throw new Error("UPC-A requires 11-12 digits");
|
|
679
634
|
}
|
|
680
|
-
return
|
|
635
|
+
return printBarcode(BarcodeType.UPC_A, data.slice(0, 12));
|
|
681
636
|
};
|
|
682
|
-
exports.printBarcodeUPCA = printBarcodeUPCA;
|
|
683
637
|
/**
|
|
684
638
|
* Print UPC-E barcode
|
|
685
639
|
* Requires 6-8 digits
|
|
686
640
|
*/
|
|
687
|
-
const printBarcodeUPCE = (data) => {
|
|
641
|
+
export const printBarcodeUPCE = (data) => {
|
|
688
642
|
if (!/^\d{6,8}$/.test(data)) {
|
|
689
643
|
throw new Error("UPC-E requires 6-8 digits");
|
|
690
644
|
}
|
|
691
|
-
return
|
|
645
|
+
return printBarcode(BarcodeType.UPC_E, data);
|
|
692
646
|
};
|
|
693
|
-
exports.printBarcodeUPCE = printBarcodeUPCE;
|
|
694
647
|
/**
|
|
695
648
|
* Print EAN-13 barcode
|
|
696
649
|
* Requires 12-13 digits
|
|
697
650
|
*/
|
|
698
|
-
const printBarcodeEAN13 = (data) => {
|
|
651
|
+
export const printBarcodeEAN13 = (data) => {
|
|
699
652
|
if (!/^\d{12,13}$/.test(data)) {
|
|
700
653
|
throw new Error("EAN-13 requires 12-13 digits");
|
|
701
654
|
}
|
|
702
|
-
return
|
|
655
|
+
return printBarcode(BarcodeType.EAN13, data.slice(0, 13));
|
|
703
656
|
};
|
|
704
|
-
exports.printBarcodeEAN13 = printBarcodeEAN13;
|
|
705
657
|
/**
|
|
706
658
|
* Print EAN-8 barcode
|
|
707
659
|
* Requires 7-8 digits
|
|
708
660
|
*/
|
|
709
|
-
const printBarcodeEAN8 = (data) => {
|
|
661
|
+
export const printBarcodeEAN8 = (data) => {
|
|
710
662
|
if (!/^\d{7,8}$/.test(data)) {
|
|
711
663
|
throw new Error("EAN-8 requires 7-8 digits");
|
|
712
664
|
}
|
|
713
|
-
return
|
|
665
|
+
return printBarcode(BarcodeType.EAN8, data);
|
|
714
666
|
};
|
|
715
|
-
exports.printBarcodeEAN8 = printBarcodeEAN8;
|
|
716
667
|
/**
|
|
717
668
|
* Print CODE39 barcode
|
|
718
669
|
* Supports: 0-9, A-Z, space, and symbols ($ % + - . /)
|
|
719
670
|
*/
|
|
720
|
-
const printBarcodeCODE39 = (data) => {
|
|
671
|
+
export const printBarcodeCODE39 = (data) => {
|
|
721
672
|
if (!/^[0-9A-Z $%+\-.\/]+$/.test(data)) {
|
|
722
673
|
throw new Error("CODE39 supports: 0-9, A-Z, space, $%+-./ only");
|
|
723
674
|
}
|
|
724
|
-
return
|
|
675
|
+
return printBarcode(BarcodeType.CODE39, data);
|
|
725
676
|
};
|
|
726
|
-
exports.printBarcodeCODE39 = printBarcodeCODE39;
|
|
727
677
|
/**
|
|
728
678
|
* Print ITF barcode (Interleaved 2 of 5)
|
|
729
679
|
* Requires even number of digits
|
|
730
680
|
*/
|
|
731
|
-
const printBarcodeITF = (data) => {
|
|
681
|
+
export const printBarcodeITF = (data) => {
|
|
732
682
|
if (!/^\d+$/.test(data) || data.length % 2 !== 0) {
|
|
733
683
|
throw new Error("ITF requires even number of digits");
|
|
734
684
|
}
|
|
735
|
-
return
|
|
685
|
+
return printBarcode(BarcodeType.ITF, data);
|
|
736
686
|
};
|
|
737
|
-
exports.printBarcodeITF = printBarcodeITF;
|
|
738
687
|
/**
|
|
739
688
|
* Print CODABAR barcode
|
|
740
689
|
* Supports: 0-9, A-D, and symbols ($ + - . / :)
|
|
741
690
|
*/
|
|
742
|
-
const printBarcodeCODABAR = (data) => {
|
|
691
|
+
export const printBarcodeCODABAR = (data) => {
|
|
743
692
|
if (!/^[A-D][0-9A-D $+\-.\/:]*[A-D]$/.test(data)) {
|
|
744
693
|
throw new Error("CODABAR must start and end with A-D, and contain 0-9, A-D, $+-./:");
|
|
745
694
|
}
|
|
746
|
-
return
|
|
695
|
+
return printBarcode(BarcodeType.CODABAR, data);
|
|
747
696
|
};
|
|
748
|
-
exports.printBarcodeCODABAR = printBarcodeCODABAR;
|
|
749
697
|
/**
|
|
750
698
|
* Print CODE93 barcode
|
|
751
699
|
* Supports all ASCII characters (0-127)
|
|
752
700
|
*/
|
|
753
|
-
const printBarcodeCODE93 = (data) => {
|
|
754
|
-
return
|
|
701
|
+
export const printBarcodeCODE93 = (data) => {
|
|
702
|
+
return printBarcodeWithLength(BarcodeType.CODE93, data);
|
|
755
703
|
};
|
|
756
|
-
exports.printBarcodeCODE93 = printBarcodeCODE93;
|
|
757
704
|
/**
|
|
758
705
|
* Print CODE128 barcode
|
|
759
706
|
* Supports all ASCII characters (0-127)
|
|
760
707
|
*/
|
|
761
|
-
const printBarcodeCODE128 = (data) => {
|
|
762
|
-
return
|
|
708
|
+
export const printBarcodeCODE128 = (data) => {
|
|
709
|
+
return printBarcodeWithLength(BarcodeType.CODE128, data);
|
|
763
710
|
};
|
|
764
|
-
exports.printBarcodeCODE128 = printBarcodeCODE128;
|
|
765
711
|
// ============================================================================
|
|
766
712
|
// 2D CODES - PDF417
|
|
767
713
|
// ============================================================================
|
|
@@ -773,64 +719,58 @@ exports.printBarcodeCODE128 = printBarcodeCODE128;
|
|
|
773
719
|
* Set PDF417 number of columns
|
|
774
720
|
* fn = 0x41, n = number of columns (0 or 1-30)
|
|
775
721
|
*/
|
|
776
|
-
const setPDF417Columns = (columns) => {
|
|
722
|
+
export const setPDF417Columns = (columns) => {
|
|
777
723
|
const col = Math.max(0, Math.min(30, columns));
|
|
778
|
-
return [
|
|
724
|
+
return [GS, 0x28, 0x6b, 0x03, 0x00, 0x30, 0x41, col];
|
|
779
725
|
};
|
|
780
|
-
exports.setPDF417Columns = setPDF417Columns;
|
|
781
726
|
/**
|
|
782
727
|
* Set PDF417 number of rows
|
|
783
728
|
* fn = 0x42, n = number of rows (0 or 3-90)
|
|
784
729
|
*/
|
|
785
|
-
const setPDF417Rows = (rows) => {
|
|
730
|
+
export const setPDF417Rows = (rows) => {
|
|
786
731
|
const row = rows === 0 ? 0 : Math.max(3, Math.min(90, rows));
|
|
787
|
-
return [
|
|
732
|
+
return [GS, 0x28, 0x6b, 0x03, 0x00, 0x30, 0x42, row];
|
|
788
733
|
};
|
|
789
|
-
exports.setPDF417Rows = setPDF417Rows;
|
|
790
734
|
/**
|
|
791
735
|
* Set PDF417 module width
|
|
792
736
|
* fn = 0x43, n = module width (2-8 dots)
|
|
793
737
|
*/
|
|
794
|
-
const setPDF417Width = (width) => {
|
|
738
|
+
export const setPDF417Width = (width) => {
|
|
795
739
|
const w = Math.max(2, Math.min(8, width));
|
|
796
|
-
return [
|
|
740
|
+
return [GS, 0x28, 0x6b, 0x03, 0x00, 0x30, 0x43, w];
|
|
797
741
|
};
|
|
798
|
-
exports.setPDF417Width = setPDF417Width;
|
|
799
742
|
/**
|
|
800
743
|
* Set PDF417 row height
|
|
801
744
|
* fn = 0x44, n = row height (2-8 dots)
|
|
802
745
|
*/
|
|
803
|
-
const setPDF417RowHeight = (height) => {
|
|
746
|
+
export const setPDF417RowHeight = (height) => {
|
|
804
747
|
const h = Math.max(2, Math.min(8, height));
|
|
805
|
-
return [
|
|
748
|
+
return [GS, 0x28, 0x6b, 0x03, 0x00, 0x30, 0x44, h];
|
|
806
749
|
};
|
|
807
|
-
exports.setPDF417RowHeight = setPDF417RowHeight;
|
|
808
750
|
/**
|
|
809
751
|
* Set PDF417 error correction level
|
|
810
752
|
* fn = 0x45, m = 48 (standard mode), n = level (0-8)
|
|
811
753
|
*/
|
|
812
|
-
const setPDF417ErrorCorrection = (level) => {
|
|
754
|
+
export const setPDF417ErrorCorrection = (level) => {
|
|
813
755
|
const lvl = Math.max(0, Math.min(8, level));
|
|
814
|
-
return [
|
|
756
|
+
return [GS, 0x28, 0x6b, 0x04, 0x00, 0x30, 0x45, 0x30, lvl];
|
|
815
757
|
};
|
|
816
|
-
exports.setPDF417ErrorCorrection = setPDF417ErrorCorrection;
|
|
817
758
|
/**
|
|
818
759
|
* Store PDF417 data
|
|
819
760
|
* fn = 0x50, m = 48 (standard mode), followed by data
|
|
820
761
|
*/
|
|
821
|
-
const storePDF417Data = (data) => {
|
|
762
|
+
export const storePDF417Data = (data) => {
|
|
822
763
|
const bytes = new TextEncoder().encode(data);
|
|
823
764
|
const pL = (bytes.length + 3) & 0xff;
|
|
824
765
|
const pH = ((bytes.length + 3) >> 8) & 0xff;
|
|
825
|
-
return [
|
|
766
|
+
return [GS, 0x28, 0x6b, pL, pH, 0x30, 0x50, 0x30, ...Array.from(bytes)];
|
|
826
767
|
};
|
|
827
|
-
exports.storePDF417Data = storePDF417Data;
|
|
828
768
|
/**
|
|
829
769
|
* Print PDF417 symbol
|
|
830
770
|
* fn = 0x51, m = 48 (standard mode)
|
|
831
771
|
*/
|
|
832
|
-
const printPDF417 = () => [
|
|
833
|
-
|
|
772
|
+
export const printPDF417 = () => [
|
|
773
|
+
GS,
|
|
834
774
|
0x28,
|
|
835
775
|
0x6b,
|
|
836
776
|
0x03,
|
|
@@ -839,33 +779,31 @@ const printPDF417 = () => [
|
|
|
839
779
|
0x51,
|
|
840
780
|
0x30,
|
|
841
781
|
];
|
|
842
|
-
exports.printPDF417 = printPDF417;
|
|
843
782
|
/**
|
|
844
783
|
* Generate complete PDF417 barcode
|
|
845
784
|
* Convenience function that combines all PDF417 commands
|
|
846
785
|
*/
|
|
847
|
-
const generatePDF417 = (data, options) => {
|
|
786
|
+
export const generatePDF417 = (data, options) => {
|
|
848
787
|
const commands = [];
|
|
849
788
|
if (options?.columns !== undefined) {
|
|
850
|
-
commands.push(...
|
|
789
|
+
commands.push(...setPDF417Columns(options.columns));
|
|
851
790
|
}
|
|
852
791
|
if (options?.rows !== undefined) {
|
|
853
|
-
commands.push(...
|
|
792
|
+
commands.push(...setPDF417Rows(options.rows));
|
|
854
793
|
}
|
|
855
794
|
if (options?.width !== undefined) {
|
|
856
|
-
commands.push(...
|
|
795
|
+
commands.push(...setPDF417Width(options.width));
|
|
857
796
|
}
|
|
858
797
|
if (options?.rowHeight !== undefined) {
|
|
859
|
-
commands.push(...
|
|
798
|
+
commands.push(...setPDF417RowHeight(options.rowHeight));
|
|
860
799
|
}
|
|
861
800
|
if (options?.errorCorrection !== undefined) {
|
|
862
|
-
commands.push(...
|
|
801
|
+
commands.push(...setPDF417ErrorCorrection(options.errorCorrection));
|
|
863
802
|
}
|
|
864
|
-
commands.push(...
|
|
865
|
-
commands.push(...
|
|
803
|
+
commands.push(...storePDF417Data(data));
|
|
804
|
+
commands.push(...printPDF417());
|
|
866
805
|
return commands;
|
|
867
806
|
};
|
|
868
|
-
exports.generatePDF417 = generatePDF417;
|
|
869
807
|
// ============================================================================
|
|
870
808
|
// CHARACTER EFFECTS (ADVANCED)
|
|
871
809
|
// ============================================================================
|
|
@@ -875,27 +813,26 @@ exports.generatePDF417 = generatePDF417;
|
|
|
875
813
|
* Bits 0-2: Width (0-7 for 1x-8x)
|
|
876
814
|
* Bits 4-6: Height (0-7 for 1x-8x)
|
|
877
815
|
*/
|
|
878
|
-
const selectCharacterSize = (widthMultiplier, heightMultiplier) => {
|
|
816
|
+
export const selectCharacterSize = (widthMultiplier, heightMultiplier) => {
|
|
879
817
|
const w = Math.max(0, Math.min(7, widthMultiplier - 1));
|
|
880
818
|
const h = Math.max(0, Math.min(7, heightMultiplier - 1));
|
|
881
819
|
const n = (w & 0x07) | ((h & 0x07) << 4);
|
|
882
|
-
return [
|
|
820
|
+
return [GS, 0x21, n];
|
|
883
821
|
};
|
|
884
|
-
exports.selectCharacterSize = selectCharacterSize;
|
|
885
822
|
/**
|
|
886
823
|
* GS B n - Turn white/black reverse printing mode on/off
|
|
887
824
|
* n = 0 or 48: Turn off white/black reverse mode
|
|
888
825
|
* n = 1 or 49: Turn on white/black reverse mode
|
|
889
826
|
*/
|
|
890
|
-
|
|
891
|
-
|
|
827
|
+
export const REVERSE_PRINT_ON = [GS, 0x42, 0x01];
|
|
828
|
+
export const REVERSE_PRINT_OFF = [GS, 0x42, 0x00];
|
|
892
829
|
/**
|
|
893
830
|
* GS ( N pL pH fn n - Select character effects
|
|
894
831
|
* fn = 48: Set character color
|
|
895
832
|
* fn = 49: Set character smoothing
|
|
896
833
|
*/
|
|
897
|
-
const setCharacterColor = (color) => [
|
|
898
|
-
|
|
834
|
+
export const setCharacterColor = (color) => [
|
|
835
|
+
GS,
|
|
899
836
|
0x28,
|
|
900
837
|
0x4e,
|
|
901
838
|
0x02,
|
|
@@ -903,9 +840,8 @@ const setCharacterColor = (color) => [
|
|
|
903
840
|
0x30,
|
|
904
841
|
color,
|
|
905
842
|
];
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
exports.GS,
|
|
843
|
+
export const setCharacterSmoothing = (enabled) => [
|
|
844
|
+
GS,
|
|
909
845
|
0x28,
|
|
910
846
|
0x4e,
|
|
911
847
|
0x02,
|
|
@@ -913,7 +849,6 @@ const setCharacterSmoothing = (enabled) => [
|
|
|
913
849
|
0x31,
|
|
914
850
|
enabled ? 0x01 : 0x00,
|
|
915
851
|
];
|
|
916
|
-
exports.setCharacterSmoothing = setCharacterSmoothing;
|
|
917
852
|
// ============================================================================
|
|
918
853
|
// STATUS COMMANDS
|
|
919
854
|
// ============================================================================
|
|
@@ -921,49 +856,45 @@ exports.setCharacterSmoothing = setCharacterSmoothing;
|
|
|
921
856
|
* GS a n - Enable/disable Automatic Status Back (ASB)
|
|
922
857
|
* n is a bitmask for status types to enable
|
|
923
858
|
*/
|
|
924
|
-
const enableASB = (statusBits) => [
|
|
925
|
-
|
|
859
|
+
export const enableASB = (statusBits) => [
|
|
860
|
+
GS,
|
|
926
861
|
0x61,
|
|
927
862
|
statusBits,
|
|
928
863
|
];
|
|
929
|
-
|
|
930
|
-
const disableASB = () => [exports.GS, 0x61, 0x00];
|
|
931
|
-
exports.disableASB = disableASB;
|
|
864
|
+
export const disableASB = () => [GS, 0x61, 0x00];
|
|
932
865
|
/**
|
|
933
866
|
* Printer ID types for GS I command
|
|
934
867
|
*/
|
|
935
|
-
var PrinterIDType;
|
|
868
|
+
export var PrinterIDType;
|
|
936
869
|
(function (PrinterIDType) {
|
|
937
870
|
PrinterIDType[PrinterIDType["PRINTER_MODEL"] = 1] = "PRINTER_MODEL";
|
|
938
871
|
PrinterIDType[PrinterIDType["TYPE_ID"] = 2] = "TYPE_ID";
|
|
939
872
|
PrinterIDType[PrinterIDType["ROM_VERSION"] = 65] = "ROM_VERSION";
|
|
940
873
|
PrinterIDType[PrinterIDType["FONT_TYPE"] = 66] = "FONT_TYPE";
|
|
941
874
|
PrinterIDType[PrinterIDType["MANUFACTURER"] = 67] = "MANUFACTURER";
|
|
942
|
-
})(PrinterIDType || (
|
|
875
|
+
})(PrinterIDType || (PrinterIDType = {}));
|
|
943
876
|
/**
|
|
944
877
|
* GS I n - Transmit printer ID
|
|
945
878
|
*/
|
|
946
|
-
const requestPrinterID = (type) => [
|
|
947
|
-
|
|
879
|
+
export const requestPrinterID = (type) => [
|
|
880
|
+
GS,
|
|
948
881
|
0x49,
|
|
949
882
|
type,
|
|
950
883
|
];
|
|
951
|
-
exports.requestPrinterID = requestPrinterID;
|
|
952
884
|
/**
|
|
953
885
|
* Status types for GS r command
|
|
954
886
|
*/
|
|
955
|
-
var StatusType;
|
|
887
|
+
export var StatusType;
|
|
956
888
|
(function (StatusType) {
|
|
957
889
|
StatusType[StatusType["PAPER_SENSOR"] = 1] = "PAPER_SENSOR";
|
|
958
890
|
StatusType[StatusType["DRAWER_SENSOR"] = 2] = "DRAWER_SENSOR";
|
|
959
891
|
StatusType[StatusType["INK_SENSOR"] = 4] = "INK_SENSOR";
|
|
960
892
|
StatusType[StatusType["PAPER_ROLL_SENSOR"] = 18] = "PAPER_ROLL_SENSOR";
|
|
961
|
-
})(StatusType || (
|
|
893
|
+
})(StatusType || (StatusType = {}));
|
|
962
894
|
/**
|
|
963
895
|
* GS r n - Transmit status
|
|
964
896
|
*/
|
|
965
|
-
const requestStatus = (type) => [
|
|
966
|
-
exports.requestStatus = requestStatus;
|
|
897
|
+
export const requestStatus = (type) => [GS, 0x72, type];
|
|
967
898
|
// ============================================================================
|
|
968
899
|
// MARGINS & PRINT AREA
|
|
969
900
|
// ============================================================================
|
|
@@ -971,22 +902,20 @@ exports.requestStatus = requestStatus;
|
|
|
971
902
|
* GS L nL nH - Set left margin
|
|
972
903
|
* Left margin = ((nH × 256) + nL) × (horizontal motion unit)
|
|
973
904
|
*/
|
|
974
|
-
const setLeftMargin = (dots) => {
|
|
905
|
+
export const setLeftMargin = (dots) => {
|
|
975
906
|
const nL = dots & 0xff;
|
|
976
907
|
const nH = (dots >> 8) & 0xff;
|
|
977
|
-
return [
|
|
908
|
+
return [GS, 0x4c, nL, nH];
|
|
978
909
|
};
|
|
979
|
-
exports.setLeftMargin = setLeftMargin;
|
|
980
910
|
/**
|
|
981
911
|
* GS W nL nH - Set printing area width
|
|
982
912
|
* Width = ((nH × 256) + nL) × (horizontal motion unit)
|
|
983
913
|
*/
|
|
984
|
-
const setPrintingAreaWidth = (dots) => {
|
|
914
|
+
export const setPrintingAreaWidth = (dots) => {
|
|
985
915
|
const nL = dots & 0xff;
|
|
986
916
|
const nH = (dots >> 8) & 0xff;
|
|
987
|
-
return [
|
|
917
|
+
return [GS, 0x57, nL, nH];
|
|
988
918
|
};
|
|
989
|
-
exports.setPrintingAreaWidth = setPrintingAreaWidth;
|
|
990
919
|
// ============================================================================
|
|
991
920
|
// MACRO FUNCTIONS
|
|
992
921
|
// ============================================================================
|
|
@@ -995,22 +924,21 @@ exports.setPrintingAreaWidth = setPrintingAreaWidth;
|
|
|
995
924
|
* First call starts macro definition
|
|
996
925
|
* Second call ends macro definition
|
|
997
926
|
*/
|
|
998
|
-
|
|
999
|
-
|
|
927
|
+
export const START_MACRO = [GS, 0x3a];
|
|
928
|
+
export const END_MACRO = [GS, 0x3a];
|
|
1000
929
|
/**
|
|
1001
930
|
* GS ^ r t m - Execute macro
|
|
1002
931
|
* r: Number of times to execute macro (0-255)
|
|
1003
932
|
* t: Waiting time between executions (0-255, units of 100ms)
|
|
1004
933
|
* m: Macro execution mode (0 or 1)
|
|
1005
934
|
*/
|
|
1006
|
-
const executeMacro = (repeatCount, waitTime, mode) => [
|
|
1007
|
-
|
|
935
|
+
export const executeMacro = (repeatCount, waitTime, mode) => [
|
|
936
|
+
GS,
|
|
1008
937
|
0x5e,
|
|
1009
938
|
Math.max(0, Math.min(255, repeatCount)),
|
|
1010
939
|
Math.max(0, Math.min(255, waitTime)),
|
|
1011
940
|
mode,
|
|
1012
941
|
];
|
|
1013
|
-
exports.executeMacro = executeMacro;
|
|
1014
942
|
// ============================================================================
|
|
1015
943
|
// MISCELLANEOUS
|
|
1016
944
|
// ============================================================================
|
|
@@ -1019,13 +947,13 @@ exports.executeMacro = executeMacro;
|
|
|
1019
947
|
* n = 0 or 48: Turn off unidirectional printing
|
|
1020
948
|
* n = 1 or 49: Turn on unidirectional printing
|
|
1021
949
|
*/
|
|
1022
|
-
|
|
1023
|
-
|
|
950
|
+
export const UNIDIRECTIONAL_ON = [ESC, 0x55, 0x01];
|
|
951
|
+
export const UNIDIRECTIONAL_OFF = [ESC, 0x55, 0x00];
|
|
1024
952
|
/**
|
|
1025
953
|
* CAN - Cancel print data in page mode
|
|
1026
954
|
* Deletes all print data in the current printable area
|
|
1027
955
|
*/
|
|
1028
|
-
|
|
956
|
+
export const CANCEL = [CAN];
|
|
1029
957
|
/**
|
|
1030
958
|
* ESC ( A pL pH n m r t - Execute test print
|
|
1031
959
|
* pL pH = 2 (fixed)
|
|
@@ -1034,8 +962,8 @@ exports.CANCEL = [exports.CAN];
|
|
|
1034
962
|
* r = number of times to repeat
|
|
1035
963
|
* t = interval time
|
|
1036
964
|
*/
|
|
1037
|
-
const executeTestPrint = (pattern, mode, repeat) => [
|
|
1038
|
-
|
|
965
|
+
export const executeTestPrint = (pattern, mode, repeat) => [
|
|
966
|
+
ESC,
|
|
1039
967
|
0x28,
|
|
1040
968
|
0x41,
|
|
1041
969
|
0x02,
|
|
@@ -1045,4 +973,3 @@ const executeTestPrint = (pattern, mode, repeat) => [
|
|
|
1045
973
|
repeat,
|
|
1046
974
|
0x00,
|
|
1047
975
|
];
|
|
1048
|
-
exports.executeTestPrint = executeTestPrint;
|