@pisell/utils 1.0.71 → 1.0.73
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/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +11 -0
- package/es/arrayUtils.d.ts +4 -1
- package/es/arrayUtils.js +15 -24
- package/es/common/stateHelper.d.ts +6 -2
- package/es/common/stateHelper.js +22 -24
- package/es/common/types.d.ts +13 -10
- package/es/componentStorage.d.ts +27 -25
- package/es/componentStorage.js +94 -130
- package/es/constants/index.js +7 -9
- package/es/date.d.ts +6 -3
- package/es/date.js +36 -53
- package/es/document.d.ts +6 -3
- package/es/document.js +43 -67
- package/es/escPosPrinter/EscPosPrinter.js +353 -490
- package/es/escPosPrinter/index.d.ts +9 -9
- package/es/escPosPrinter/index.js +37 -52
- package/es/format.d.ts +12 -11
- package/es/format.js +90 -116
- package/es/image.d.ts +13 -10
- package/es/image.js +48 -60
- package/es/index.d.ts +38 -23
- package/es/index.js +39 -34
- package/es/jsBridge/index.d.ts +8 -4
- package/es/jsBridge/index.js +57 -56
- package/es/jsBridge/regDeviceApi.js +107 -149
- package/es/jsBridge/types.d.ts +95 -115
- package/es/locales.d.ts +11 -8
- package/es/locales.js +77 -96
- package/es/log.d.ts +11 -6
- package/es/log.js +37 -59
- package/es/miniRedux.d.ts +20 -13
- package/es/miniRedux.js +42 -78
- package/es/number-input/hooks/useNumberInputState.d.ts +6 -2
- package/es/number-input/hooks/useNumberInputState.js +71 -128
- package/es/number-input/types.d.ts +88 -88
- package/es/number-input/utils/formatter.d.ts +13 -10
- package/es/number-input/utils/formatter.js +51 -77
- package/es/number-input/utils/validation.d.ts +7 -2
- package/es/number-input/utils/validation.js +51 -66
- package/es/otherUtils.d.ts +12 -9
- package/es/otherUtils.js +71 -129
- package/es/platform.d.ts +17 -9
- package/es/platform.js +78 -85
- package/es/select/hooks/useDebouncedSearch.d.ts +4 -1
- package/es/select/hooks/useDebouncedSearch.js +39 -53
- package/es/select/hooks/useSelectState.d.ts +7 -7
- package/es/select/hooks/useSelectState.js +56 -113
- package/es/select/index.d.ts +7 -8
- package/es/select/types.d.ts +211 -211
- package/es/select/utils/filterOptions.d.ts +7 -6
- package/es/select/utils/filterOptions.js +26 -31
- package/es/select/utils/helpers.d.ts +10 -9
- package/es/select/utils/helpers.js +42 -52
- package/es/select/utils/index.d.ts +4 -7
- package/es/select/utils/sortOptions.d.ts +6 -5
- package/es/select/utils/sortOptions.js +19 -31
- package/es/select/utils/tagAggregation.d.ts +6 -6
- package/es/select/utils/tagAggregation.js +34 -47
- package/es/text-input/hooks/useTextInputState.d.ts +6 -2
- package/es/text-input/hooks/useTextInputState.js +69 -126
- package/es/text-input/types.d.ts +48 -48
- package/es/text-input/utils/validation.d.ts +7 -2
- package/es/text-input/utils/validation.js +50 -70
- package/es/typeUtils.d.ts +11 -8
- package/es/typeUtils.js +61 -84
- package/es/walletValidity.d.ts +36 -34
- package/es/walletValidity.js +332 -456
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +16 -0
- package/lib/_virtual/_rolldown/runtime.js +23 -0
- package/lib/arrayUtils.d.ts +4 -1
- package/lib/arrayUtils.js +14 -39
- package/lib/common/stateHelper.d.ts +6 -2
- package/lib/common/stateHelper.js +21 -32
- package/lib/common/types.d.ts +13 -10
- package/lib/componentStorage.d.ts +27 -25
- package/lib/componentStorage.js +96 -126
- package/lib/constants/index.js +7 -36
- package/lib/date.d.ts +6 -3
- package/lib/date.js +43 -65
- package/lib/document.d.ts +6 -3
- package/lib/document.js +46 -62
- package/lib/escPosPrinter/EscPosPrinter.js +327 -403
- package/lib/escPosPrinter/index.d.ts +9 -9
- package/lib/escPosPrinter/index.js +38 -84
- package/lib/format.d.ts +12 -11
- package/lib/format.js +91 -99
- package/lib/image.d.ts +13 -10
- package/lib/image.js +48 -74
- package/lib/index.d.ts +38 -23
- package/lib/index.js +115 -78
- package/lib/jsBridge/index.d.ts +8 -4
- package/lib/jsBridge/index.js +58 -77
- package/lib/jsBridge/regDeviceApi.js +106 -153
- package/lib/jsBridge/types.d.ts +95 -115
- package/lib/locales.d.ts +11 -8
- package/lib/locales.js +79 -90
- package/lib/log.d.ts +11 -6
- package/lib/log.js +37 -61
- package/lib/miniRedux.d.ts +20 -13
- package/lib/miniRedux.js +43 -92
- package/lib/number-input/hooks/useNumberInputState.d.ts +6 -2
- package/lib/number-input/hooks/useNumberInputState.js +71 -81
- package/lib/number-input/types.d.ts +88 -88
- package/lib/number-input/utils/formatter.d.ts +13 -10
- package/lib/number-input/utils/formatter.js +52 -49
- package/lib/number-input/utils/validation.d.ts +7 -2
- package/lib/number-input/utils/validation.js +50 -52
- package/lib/otherUtils.d.ts +12 -9
- package/lib/otherUtils.js +86 -98
- package/lib/platform.d.ts +17 -9
- package/lib/platform.js +85 -122
- package/lib/select/hooks/useDebouncedSearch.d.ts +4 -1
- package/lib/select/hooks/useDebouncedSearch.js +40 -41
- package/lib/select/hooks/useSelectState.d.ts +7 -7
- package/lib/select/hooks/useSelectState.js +58 -93
- package/lib/select/index.d.ts +7 -8
- package/lib/select/types.d.ts +211 -211
- package/lib/select/utils/filterOptions.d.ts +7 -6
- package/lib/select/utils/filterOptions.js +26 -37
- package/lib/select/utils/helpers.d.ts +10 -9
- package/lib/select/utils/helpers.js +45 -41
- package/lib/select/utils/index.d.ts +4 -7
- package/lib/select/utils/sortOptions.d.ts +6 -5
- package/lib/select/utils/sortOptions.js +18 -39
- package/lib/select/utils/tagAggregation.d.ts +6 -6
- package/lib/select/utils/tagAggregation.js +33 -41
- package/lib/text-input/hooks/useTextInputState.d.ts +6 -2
- package/lib/text-input/hooks/useTextInputState.js +69 -79
- package/lib/text-input/types.d.ts +48 -48
- package/lib/text-input/utils/validation.d.ts +7 -2
- package/lib/text-input/utils/validation.js +49 -58
- package/lib/typeUtils.d.ts +11 -8
- package/lib/typeUtils.js +68 -73
- package/lib/walletValidity.d.ts +36 -34
- package/lib/walletValidity.js +345 -317
- package/package.json +1 -2
- package/es/common/index.d.ts +0 -5
- package/es/common/index.js +0 -5
- package/es/common/types.js +0 -1
- package/es/constants/index.d.ts +0 -7
- package/es/firebase/config/index.d.ts +0 -13
- package/es/firebase/config/index.js +0 -54
- package/es/firebase/index.d.ts +0 -28
- package/es/firebase/index.js +0 -232
- package/es/jsBridge/types.js +0 -1
- package/es/number-input/hooks/index.d.ts +0 -4
- package/es/number-input/hooks/index.js +0 -5
- package/es/number-input/index.d.ts +0 -14
- package/es/number-input/index.js +0 -21
- package/es/number-input/types.js +0 -1
- package/es/number-input/utils/index.d.ts +0 -7
- package/es/number-input/utils/index.js +0 -8
- package/es/select/hooks/index.d.ts +0 -5
- package/es/select/hooks/index.js +0 -6
- package/es/select/index.js +0 -13
- package/es/select/types.js +0 -1
- package/es/select/utils/index.js +0 -8
- package/es/text-input/hooks/index.d.ts +0 -4
- package/es/text-input/hooks/index.js +0 -5
- package/es/text-input/index.d.ts +0 -14
- package/es/text-input/index.js +0 -20
- package/es/text-input/types.js +0 -1
- package/es/text-input/utils/index.d.ts +0 -5
- package/es/text-input/utils/index.js +0 -7
- package/lib/common/index.d.ts +0 -5
- package/lib/common/index.js +0 -29
- package/lib/common/types.js +0 -17
- package/lib/constants/index.d.ts +0 -7
- package/lib/firebase/config/index.d.ts +0 -13
- package/lib/firebase/config/index.js +0 -79
- package/lib/firebase/index.d.ts +0 -28
- package/lib/firebase/index.js +0 -180
- package/lib/jsBridge/types.js +0 -17
- package/lib/number-input/hooks/index.d.ts +0 -4
- package/lib/number-input/hooks/index.js +0 -29
- package/lib/number-input/index.d.ts +0 -14
- package/lib/number-input/index.js +0 -41
- package/lib/number-input/types.js +0 -17
- package/lib/number-input/utils/index.d.ts +0 -7
- package/lib/number-input/utils/index.js +0 -39
- package/lib/select/hooks/index.d.ts +0 -5
- package/lib/select/hooks/index.js +0 -34
- package/lib/select/index.js +0 -53
- package/lib/select/types.js +0 -17
- package/lib/select/utils/index.js +0 -48
- package/lib/text-input/hooks/index.d.ts +0 -4
- package/lib/text-input/hooks/index.js +0 -29
- package/lib/text-input/index.d.ts +0 -14
- package/lib/text-input/index.js +0 -35
- package/lib/text-input/types.js +0 -17
- package/lib/text-input/utils/index.d.ts +0 -5
- package/lib/text-input/utils/index.js +0 -32
|
@@ -1,538 +1,401 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// HRI above the barcode
|
|
12
|
-
export var HRI_POS_ABOVE = 1;
|
|
13
|
-
// HRI below the barcode
|
|
14
|
-
export var HRI_POS_BELOW = 2;
|
|
15
|
-
var EscPosPrinter = function EscPosPrinter(dotsPerLine) {
|
|
16
|
-
if (dotsPerLine != 384 && dotsPerLine != 576)
|
|
17
|
-
// Print width in dots. 384 for 58mm and 576 for 80mm
|
|
18
|
-
dotsPerLine = 384;
|
|
19
|
-
this.widthOfColumns = new Array(MAX_COLUMNS);
|
|
20
|
-
this.dotsPerLine = dotsPerLine;
|
|
21
|
-
this.charHSize = 1;
|
|
22
|
-
this.orderData = "";
|
|
1
|
+
const ALIGN_LEFT = 0;
|
|
2
|
+
const ALIGN_CENTER = 1;
|
|
3
|
+
const ALIGN_RIGHT = 2;
|
|
4
|
+
const EscPosPrinter = function(dotsPerLine) {
|
|
5
|
+
if (dotsPerLine != 384 && dotsPerLine != 576) dotsPerLine = 384;
|
|
6
|
+
this.widthOfColumns = new Array(6);
|
|
7
|
+
this.dotsPerLine = dotsPerLine;
|
|
8
|
+
this.charHSize = 1;
|
|
9
|
+
this.orderData = "";
|
|
23
10
|
};
|
|
24
11
|
function _numToHexStr(n, bytes) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
12
|
+
var str = "";
|
|
13
|
+
var v;
|
|
14
|
+
for (var i = 0; i < bytes; i++) {
|
|
15
|
+
v = n & 255;
|
|
16
|
+
if (v < 16) str += "0" + v.toString(16);
|
|
17
|
+
else str += v.toString(16);
|
|
18
|
+
n >>= 8;
|
|
19
|
+
}
|
|
20
|
+
return str;
|
|
33
21
|
}
|
|
34
22
|
function _unicodeToUtf8(unicode) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
23
|
+
var c1, c2, c3, c4;
|
|
24
|
+
if (unicode < 0) return "";
|
|
25
|
+
if (unicode <= 127) {
|
|
26
|
+
c1 = unicode & 127;
|
|
27
|
+
return _numToHexStr(c1, 1);
|
|
28
|
+
}
|
|
29
|
+
if (unicode <= 2047) {
|
|
30
|
+
c1 = unicode >> 6 & 31 | 192;
|
|
31
|
+
c2 = unicode & 63 | 128;
|
|
32
|
+
return _numToHexStr(c1, 1) + _numToHexStr(c2, 1);
|
|
33
|
+
}
|
|
34
|
+
if (unicode <= 65535) {
|
|
35
|
+
c1 = unicode >> 12 & 15 | 224;
|
|
36
|
+
c2 = unicode >> 6 & 63 | 128;
|
|
37
|
+
c3 = unicode & 63 | 128;
|
|
38
|
+
return _numToHexStr(c1, 1) + _numToHexStr(c2, 1) + _numToHexStr(c3, 1);
|
|
39
|
+
}
|
|
40
|
+
if (unicode <= 1114111) {
|
|
41
|
+
c1 = unicode >> 18 & 7 | 240;
|
|
42
|
+
c2 = unicode >> 12 & 63 | 128;
|
|
43
|
+
c3 = unicode >> 6 & 63 | 128;
|
|
44
|
+
c4 = unicode & 63 | 128;
|
|
45
|
+
return _numToHexStr(c1, 1) + _numToHexStr(c2, 1) + _numToHexStr(c3, 1) + _numToHexStr(c4, 1);
|
|
46
|
+
}
|
|
47
|
+
return "";
|
|
60
48
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
EscPosPrinter.prototype.clear = function () {
|
|
64
|
-
this.orderData = "";
|
|
49
|
+
EscPosPrinter.prototype.clear = function() {
|
|
50
|
+
this.orderData = "";
|
|
65
51
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
resolve(matches[1] || "");
|
|
81
|
-
} else {
|
|
82
|
-
reject(xmlobj.responseText);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
xmlobj.setRequestHeader("Content-Type", "text/plain; charset=utf-8");
|
|
87
|
-
xmlobj.send(that.orderData);
|
|
88
|
-
});
|
|
52
|
+
EscPosPrinter.prototype.print = function(host, sn, copies) {
|
|
53
|
+
var that = this;
|
|
54
|
+
return new Promise(function(resolve, reject) {
|
|
55
|
+
var xmlobj = new XMLHttpRequest();
|
|
56
|
+
xmlobj.timeout = 1e4;
|
|
57
|
+
var url = "https://" + host + "/cgi-bin/print.cgi?sn=" + sn + "&copies=" + copies;
|
|
58
|
+
xmlobj.open("POST", url, true);
|
|
59
|
+
xmlobj.onreadystatechange = function() {
|
|
60
|
+
if (xmlobj.readyState === XMLHttpRequest.DONE) if (xmlobj.status.toString(10) === "200") resolve(/task_id: (\d+)/.exec(xmlobj.responseText)[1] || "");
|
|
61
|
+
else reject(xmlobj.responseText);
|
|
62
|
+
};
|
|
63
|
+
xmlobj.setRequestHeader("Content-Type", "text/plain; charset=utf-8");
|
|
64
|
+
xmlobj.send(that.orderData);
|
|
65
|
+
});
|
|
89
66
|
};
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
reject(xmlobj.responseText);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
xmlobj.setRequestHeader("Content-Type", "text/plain; charset=utf-8");
|
|
108
|
-
xmlobj.send();
|
|
109
|
-
});
|
|
67
|
+
EscPosPrinter.prototype.queryStatus = function(host, sn, task_id) {
|
|
68
|
+
return new Promise(function(resolve, reject) {
|
|
69
|
+
var xmlobj = new XMLHttpRequest();
|
|
70
|
+
xmlobj.timeout = 1e4;
|
|
71
|
+
var url = "https://" + host + "/cgi-bin/status.cgi?sn=" + sn + "&task_id=" + task_id;
|
|
72
|
+
xmlobj.open("POST", url, true);
|
|
73
|
+
xmlobj.onreadystatechange = function() {
|
|
74
|
+
if (xmlobj.readyState === XMLHttpRequest.DONE) if (xmlobj.status.toString(10) === "200") resolve(xmlobj.responseText);
|
|
75
|
+
else reject(xmlobj.responseText);
|
|
76
|
+
};
|
|
77
|
+
xmlobj.setRequestHeader("Content-Type", "text/plain; charset=utf-8");
|
|
78
|
+
xmlobj.send();
|
|
79
|
+
});
|
|
110
80
|
};
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
// Basic ESC/POS Commands
|
|
114
|
-
//////////////////////////////////////////////////
|
|
115
|
-
|
|
116
|
-
// Append text in the order.
|
|
117
|
-
EscPosPrinter.prototype.appendText = function (str) {
|
|
118
|
-
for (var i = 0; i < str.length; i++) this.orderData += _unicodeToUtf8(str.charCodeAt(i));
|
|
81
|
+
EscPosPrinter.prototype.appendText = function(str) {
|
|
82
|
+
for (var i = 0; i < str.length; i++) this.orderData += _unicodeToUtf8(str.charCodeAt(i));
|
|
119
83
|
};
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
EscPosPrinter.prototype.lineFeed = function (n) {
|
|
123
|
-
for (var i = 0; i < n; i++) this.orderData += "0a";
|
|
84
|
+
EscPosPrinter.prototype.lineFeed = function(n) {
|
|
85
|
+
for (var i = 0; i < n; i++) this.orderData += "0a";
|
|
124
86
|
};
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
this.charHSize = 1;
|
|
129
|
-
this.orderData += "1b40";
|
|
87
|
+
EscPosPrinter.prototype.restoreDefaultSettings = function() {
|
|
88
|
+
this.charHSize = 1;
|
|
89
|
+
this.orderData += "1b40";
|
|
130
90
|
};
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
EscPosPrinter.prototype.restoreDefaultLineSpacing = function () {
|
|
134
|
-
this.orderData += "1b32";
|
|
91
|
+
EscPosPrinter.prototype.restoreDefaultLineSpacing = function() {
|
|
92
|
+
this.orderData += "1b32";
|
|
135
93
|
};
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
EscPosPrinter.prototype.setLineSpacing = function (n) {
|
|
139
|
-
if (n >= 0 && n <= 255) this.orderData += "1b33" + _numToHexStr(n, 1);
|
|
94
|
+
EscPosPrinter.prototype.setLineSpacing = function(n) {
|
|
95
|
+
if (n >= 0 && n <= 255) this.orderData += "1b33" + _numToHexStr(n, 1);
|
|
140
96
|
};
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
this.charHSize = double_w ? 2 : 1;
|
|
149
|
-
this.orderData += "1b21" + _numToHexStr(n, 1);
|
|
97
|
+
EscPosPrinter.prototype.setPrintModes = function(bold, double_h, double_w) {
|
|
98
|
+
var n = 0;
|
|
99
|
+
if (bold) n |= 8;
|
|
100
|
+
if (double_h) n |= 16;
|
|
101
|
+
if (double_w) n |= 32;
|
|
102
|
+
this.charHSize = double_w ? 2 : 1;
|
|
103
|
+
this.orderData += "1b21" + _numToHexStr(n, 1);
|
|
150
104
|
};
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
this.orderData += "1d21" + _numToHexStr(n, 1);
|
|
105
|
+
EscPosPrinter.prototype.setCharacterSize = function(h, w) {
|
|
106
|
+
var n = 0;
|
|
107
|
+
if (h >= 1 && h <= 8) n |= h - 1;
|
|
108
|
+
if (w >= 1 && w <= 8) {
|
|
109
|
+
n |= w - 1 << 4;
|
|
110
|
+
this.charHSize = w;
|
|
111
|
+
}
|
|
112
|
+
this.orderData += "1d21" + _numToHexStr(n, 1);
|
|
161
113
|
};
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
EscPosPrinter.prototype.horizontalTab = function (n) {
|
|
165
|
-
for (var i = 0; i < n; i++) this.orderData += "09";
|
|
114
|
+
EscPosPrinter.prototype.horizontalTab = function(n) {
|
|
115
|
+
for (var i = 0; i < n; i++) this.orderData += "09";
|
|
166
116
|
};
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
EscPosPrinter.prototype.setAbsolutePrintPosition = function (n) {
|
|
170
|
-
if (n >= 0 && n <= 65535) this.orderData += "1b24" + _numToHexStr(n, 2);
|
|
117
|
+
EscPosPrinter.prototype.setAbsolutePrintPosition = function(n) {
|
|
118
|
+
if (n >= 0 && n <= 65535) this.orderData += "1b24" + _numToHexStr(n, 2);
|
|
171
119
|
};
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
EscPosPrinter.prototype.setRelativePrintPosition = function (n) {
|
|
175
|
-
if (n >= -32768 && n <= 32767) this.orderData += "1b5c" + _numToHexStr(n, 2);
|
|
120
|
+
EscPosPrinter.prototype.setRelativePrintPosition = function(n) {
|
|
121
|
+
if (n >= -32768 && n <= 32767) this.orderData += "1b5c" + _numToHexStr(n, 2);
|
|
176
122
|
};
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
EscPosPrinter.prototype.setAlignment = function (n) {
|
|
180
|
-
if (n >= 0 && n <= 2) this.orderData += "1b61" + _numToHexStr(n, 1);
|
|
123
|
+
EscPosPrinter.prototype.setAlignment = function(n) {
|
|
124
|
+
if (n >= 0 && n <= 2) this.orderData += "1b61" + _numToHexStr(n, 1);
|
|
181
125
|
};
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
EscPosPrinter.prototype.cutPaper = function (fullCut) {
|
|
185
|
-
this.orderData += "1d56" + (fullCut ? "30" : "31");
|
|
126
|
+
EscPosPrinter.prototype.cutPaper = function(fullCut) {
|
|
127
|
+
this.orderData += "1d56" + (fullCut ? "30" : "31");
|
|
186
128
|
};
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
// After sending this command, the cutter will not cut until (76+n) dot lines are fed.
|
|
190
|
-
EscPosPrinter.prototype.postponedCutPaper = function (fullCut, n) {
|
|
191
|
-
if (n >= 0 && n <= 255) this.orderData += "1d56" + (fullCut ? "61" : "62") + _numToHexStr(n, 1);
|
|
129
|
+
EscPosPrinter.prototype.postponedCutPaper = function(fullCut, n) {
|
|
130
|
+
if (n >= 0 && n <= 255) this.orderData += "1d56" + (fullCut ? "61" : "62") + _numToHexStr(n, 1);
|
|
192
131
|
};
|
|
193
|
-
|
|
194
|
-
//////////////////////////////////////////////////
|
|
195
|
-
// Print in Columns
|
|
196
|
-
//////////////////////////////////////////////////
|
|
197
|
-
|
|
198
|
-
// Return the width of a character.
|
|
199
132
|
function _widthOfChar(c) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
133
|
+
if (c >= 32 && c <= 879 || c >= 65377 && c <= 65439) return 12;
|
|
134
|
+
if (c == 8208 || c >= 8211 && c <= 8214 || c >= 8216 && c <= 8217 || c >= 8220 && c <= 8221 || c >= 8229 && c <= 8230 || c >= 8240 && c <= 8243 || c == 8245 || c == 8251) return 24;
|
|
135
|
+
if (c >= 4352 && c <= 4607 || c >= 9312 && c <= 9471 || c >= 9632 && c <= 10175 || c >= 11904 && c <= 12255 || c >= 12288 && c <= 12687 || c >= 12704 && c <= 12783 || c >= 12800 && c <= 40959 || c >= 44032 && c <= 55295 || c >= 63744 && c <= 64255 || c >= 65072 && c <= 65103 || c >= 126976 && c <= 129535) return 24;
|
|
136
|
+
if (c >= 65281 && c <= 65374 || c >= 65504 && c <= 65509) return 24;
|
|
137
|
+
return 0;
|
|
205
138
|
}
|
|
206
|
-
|
|
207
|
-
|
|
139
|
+
function columnWidthWithAlignment(width, alignment) {
|
|
140
|
+
return width & 65535 | (alignment & 3) << 16;
|
|
208
141
|
}
|
|
209
142
|
function _columnWidth(v) {
|
|
210
|
-
|
|
143
|
+
return v & 65535;
|
|
211
144
|
}
|
|
212
145
|
function _columnAlignment(v) {
|
|
213
|
-
|
|
146
|
+
return v >> 16 & 3;
|
|
214
147
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
()
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
this.widthOfColumns[i] = columnWidthWithAlignment(remain, alignment);
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
this.widthOfColumns[i] = arguments[i];
|
|
235
|
-
remain -= width;
|
|
236
|
-
}
|
|
148
|
+
EscPosPrinter.prototype.setColumnWidths = function() {
|
|
149
|
+
var i, remain, width, alignment;
|
|
150
|
+
if (arguments.length == 0) return;
|
|
151
|
+
for (i = 0; i < 6; i++) this.widthOfColumns[i] = 0;
|
|
152
|
+
remain = this.dotsPerLine;
|
|
153
|
+
for (i = 0; i < arguments.length; i++) {
|
|
154
|
+
if (i == 6) return;
|
|
155
|
+
width = _columnWidth(arguments[i]);
|
|
156
|
+
alignment = _columnAlignment(arguments[i]);
|
|
157
|
+
if (width == 0 || width > remain) {
|
|
158
|
+
this.widthOfColumns[i] = columnWidthWithAlignment(remain, alignment);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
this.widthOfColumns[i] = arguments[i];
|
|
162
|
+
remain -= width;
|
|
163
|
+
}
|
|
237
164
|
};
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
()
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
if (!done) this.lineFeed(1);
|
|
304
|
-
} while (!done);
|
|
165
|
+
EscPosPrinter.prototype.printInColumns = function() {
|
|
166
|
+
var strcurr = new Array(6);
|
|
167
|
+
var strrem = new Array(6);
|
|
168
|
+
var strwidth = new Array(6);
|
|
169
|
+
var i, j, c, w, columns, width, alignment, pos;
|
|
170
|
+
var done;
|
|
171
|
+
if (arguments.length == 0) return;
|
|
172
|
+
columns = 0;
|
|
173
|
+
for (i = 0; i < arguments.length; i++) {
|
|
174
|
+
if (i == 6 || this.widthOfColumns[i] == 0) break;
|
|
175
|
+
strcurr[i] = "";
|
|
176
|
+
strrem[i] = arguments[i];
|
|
177
|
+
columns++;
|
|
178
|
+
}
|
|
179
|
+
do {
|
|
180
|
+
done = true;
|
|
181
|
+
pos = 0;
|
|
182
|
+
for (i = 0; i < columns; i++) {
|
|
183
|
+
width = _columnWidth(this.widthOfColumns[i]);
|
|
184
|
+
if (strrem[i].length == 0) {
|
|
185
|
+
pos += width;
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
done = false;
|
|
189
|
+
strcurr[i] = "";
|
|
190
|
+
strwidth[i] = 0;
|
|
191
|
+
for (j = 0; j < strrem[i].length; j++) {
|
|
192
|
+
c = strrem[i].charCodeAt(j);
|
|
193
|
+
if (c == 10) {
|
|
194
|
+
j++;
|
|
195
|
+
break;
|
|
196
|
+
} else {
|
|
197
|
+
w = _widthOfChar(c);
|
|
198
|
+
if (w == 0) {
|
|
199
|
+
c = "?";
|
|
200
|
+
w = 12;
|
|
201
|
+
}
|
|
202
|
+
w *= this.charHSize;
|
|
203
|
+
if (strwidth[i] + w > width) break;
|
|
204
|
+
else {
|
|
205
|
+
strcurr[i] += String.fromCharCode(c);
|
|
206
|
+
strwidth[i] += w;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (j < strrem[i].length) strrem[i] = strrem[i].substring(j);
|
|
211
|
+
else strrem[i] = "";
|
|
212
|
+
alignment = _columnAlignment(this.widthOfColumns[i]);
|
|
213
|
+
switch (alignment) {
|
|
214
|
+
case 1:
|
|
215
|
+
this.setAbsolutePrintPosition(pos + (width - strwidth[i]) / 2);
|
|
216
|
+
break;
|
|
217
|
+
case 2:
|
|
218
|
+
this.setAbsolutePrintPosition(pos + (width - strwidth[i]));
|
|
219
|
+
break;
|
|
220
|
+
default:
|
|
221
|
+
this.setAbsolutePrintPosition(pos);
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
this.appendText(strcurr[i]);
|
|
225
|
+
pos += width;
|
|
226
|
+
}
|
|
227
|
+
if (!done) this.lineFeed(1);
|
|
228
|
+
} while (!done);
|
|
305
229
|
};
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
this.orderData += "1d68" + _numToHexStr(height, 1);
|
|
321
|
-
this.orderData += "1d77" + _numToHexStr(module_size, 1);
|
|
322
|
-
this.orderData += "1d6b" + _numToHexStr(barcode_type, 1) + _numToHexStr(text_length, 1);
|
|
323
|
-
for (var i = 0; i < text_length; i++) this.orderData += _numToHexStr(text.charCodeAt(i), 1);
|
|
230
|
+
EscPosPrinter.prototype.appendBarcode = function(hri_pos, height, module_size, barcode_type, text) {
|
|
231
|
+
var text_length = text.length;
|
|
232
|
+
if (text_length == 0) return;
|
|
233
|
+
if (text_length > 255) text_length = 255;
|
|
234
|
+
if (height < 1) height = 1;
|
|
235
|
+
else if (height > 255) height = 255;
|
|
236
|
+
if (module_size < 1) module_size = 1;
|
|
237
|
+
else if (module_size > 6) module_size = 6;
|
|
238
|
+
this.orderData += "1d48" + _numToHexStr(hri_pos & 3, 1);
|
|
239
|
+
this.orderData += "1d6600";
|
|
240
|
+
this.orderData += "1d68" + _numToHexStr(height, 1);
|
|
241
|
+
this.orderData += "1d77" + _numToHexStr(module_size, 1);
|
|
242
|
+
this.orderData += "1d6b" + _numToHexStr(barcode_type, 1) + _numToHexStr(text_length, 1);
|
|
243
|
+
for (var i = 0; i < text_length; i++) this.orderData += _numToHexStr(text.charCodeAt(i), 1);
|
|
324
244
|
};
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
245
|
+
EscPosPrinter.prototype.appendQRcode = function(module_size, ec_level, text) {
|
|
246
|
+
var text_length = text.length;
|
|
247
|
+
if (text_length == 0) return;
|
|
248
|
+
if (text_length > 65535) text_length = 65535;
|
|
249
|
+
if (module_size < 1) module_size = 1;
|
|
250
|
+
else if (module_size > 16) module_size = 16;
|
|
251
|
+
if (ec_level < 0) ec_level = 0;
|
|
252
|
+
else if (ec_level > 3) ec_level = 3;
|
|
253
|
+
this.orderData += "1d286b040031410000";
|
|
254
|
+
this.orderData += "1d286b03003143" + _numToHexStr(module_size, 1);
|
|
255
|
+
this.orderData += "1d286b03003145" + _numToHexStr(ec_level + 48, 1);
|
|
256
|
+
this.orderData += "1d286b" + _numToHexStr(text_length + 3, 2) + "315030";
|
|
257
|
+
for (var i = 0; i < text_length; i++) this.orderData += _numToHexStr(text.charCodeAt(i), 1);
|
|
258
|
+
this.orderData += "1d286b0300315130";
|
|
339
259
|
};
|
|
340
|
-
|
|
341
|
-
//////////////////////////////////////////////////
|
|
342
|
-
// Image Printing
|
|
343
|
-
//////////////////////////////////////////////////
|
|
344
|
-
|
|
345
|
-
// Grayscale to mono - diffuse dithering.
|
|
346
260
|
function _diffuseDither(src_data, width, height) {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
}
|
|
409
|
-
b2++;
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
return dst_data;
|
|
261
|
+
if (width <= 0 || height <= 0) return null;
|
|
262
|
+
if (src_data.length < width * height) return null;
|
|
263
|
+
var bmwidth = width + 7 >> 3;
|
|
264
|
+
var dst_data = new Array(bmwidth * height);
|
|
265
|
+
var line_buffer = new Array(2 * width);
|
|
266
|
+
var i, p, q, x, y, mask;
|
|
267
|
+
var line1, line2, b1, b2, tmp;
|
|
268
|
+
var err, e1, e3, e5, e7;
|
|
269
|
+
var not_last_line;
|
|
270
|
+
line1 = 0;
|
|
271
|
+
line2 = 1;
|
|
272
|
+
for (i = 0; i < width; i++) {
|
|
273
|
+
line_buffer[i] = 0;
|
|
274
|
+
line_buffer[width + i] = src_data[i];
|
|
275
|
+
}
|
|
276
|
+
for (y = 0; y < height; y++) {
|
|
277
|
+
tmp = line1;
|
|
278
|
+
line1 = line2;
|
|
279
|
+
line2 = tmp;
|
|
280
|
+
not_last_line = y < height - 1;
|
|
281
|
+
if (not_last_line) {
|
|
282
|
+
p = (y + 1) * width;
|
|
283
|
+
for (i = 0; i < width; i++) {
|
|
284
|
+
line_buffer[line2 * width + i] = src_data[p];
|
|
285
|
+
p++;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
q = y * bmwidth;
|
|
289
|
+
for (i = 0; i < bmwidth; i++) {
|
|
290
|
+
dst_data[q] = 0;
|
|
291
|
+
q++;
|
|
292
|
+
}
|
|
293
|
+
b1 = 0;
|
|
294
|
+
b2 = 0;
|
|
295
|
+
q = y * bmwidth;
|
|
296
|
+
mask = 128;
|
|
297
|
+
for (x = 1; x <= width; x++) {
|
|
298
|
+
var idx = line1 * width + b1;
|
|
299
|
+
if (line_buffer[idx] < 128) {
|
|
300
|
+
err = line_buffer[idx];
|
|
301
|
+
dst_data[q] |= mask;
|
|
302
|
+
} else err = line_buffer[idx] - 255;
|
|
303
|
+
b1++;
|
|
304
|
+
if (mask == 1) {
|
|
305
|
+
q++;
|
|
306
|
+
mask = 128;
|
|
307
|
+
} else mask >>= 1;
|
|
308
|
+
e7 = err * 7 + 8 >> 4;
|
|
309
|
+
e5 = err * 5 + 8 >> 4;
|
|
310
|
+
e3 = err * 3 + 8 >> 4;
|
|
311
|
+
e1 = err - (e7 + e5 + e3);
|
|
312
|
+
if (x < width) line_buffer[line1 * width + b1] += e7;
|
|
313
|
+
if (not_last_line) {
|
|
314
|
+
line_buffer[line2 * width + b2] += e5;
|
|
315
|
+
if (x > 1) line_buffer[line2 * width + b2 - 1] += e3;
|
|
316
|
+
if (x < width) line_buffer[line2 * width + b2 + 1] += e1;
|
|
317
|
+
}
|
|
318
|
+
b2++;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return dst_data;
|
|
413
322
|
}
|
|
414
|
-
|
|
415
|
-
// Grayscale to mono - threshold dithering.
|
|
416
323
|
function _thresholdDither(src_data, width, height) {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
} else {
|
|
437
|
-
mask >>= 1;
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
q += bmwidth;
|
|
441
|
-
}
|
|
442
|
-
return dst_data;
|
|
324
|
+
if (width <= 0 || height <= 0) return null;
|
|
325
|
+
if (src_data.length < width * height) return null;
|
|
326
|
+
var bmwidth = width + 7 >> 3;
|
|
327
|
+
var dst_data = new Array(bmwidth * height);
|
|
328
|
+
var p = 0, q = 0, k, x, y, mask;
|
|
329
|
+
for (y = 0; y < height; y++) {
|
|
330
|
+
k = q;
|
|
331
|
+
mask = 128;
|
|
332
|
+
for (x = 0; x < width; x++) {
|
|
333
|
+
if (src_data[p] < 128) dst_data[k] |= mask;
|
|
334
|
+
p++;
|
|
335
|
+
if (mask == 1) {
|
|
336
|
+
k++;
|
|
337
|
+
mask = 128;
|
|
338
|
+
} else mask >>= 1;
|
|
339
|
+
}
|
|
340
|
+
q += bmwidth;
|
|
341
|
+
}
|
|
342
|
+
return dst_data;
|
|
443
343
|
}
|
|
444
|
-
|
|
445
|
-
// RGB to grayscale.
|
|
446
344
|
function _convertToGray(imgdata, width, height) {
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
r = imgdata.data[j++] & 0xff;
|
|
458
|
-
g = imgdata.data[j++] & 0xff;
|
|
459
|
-
b = imgdata.data[j++] & 0xff;
|
|
460
|
-
j++; // Skip the Alpha channel
|
|
461
|
-
gray_data[i++] = r * 11 + g * 16 + b * 5 >> 5 & 0xff;
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
return gray_data;
|
|
345
|
+
var gray_data = new Array(width * height);
|
|
346
|
+
var i = 0, j = 0, x, y, r, g, b;
|
|
347
|
+
for (y = 0; y < height; y++) for (x = 0; x < width; x++) {
|
|
348
|
+
r = imgdata.data[j++] & 255;
|
|
349
|
+
g = imgdata.data[j++] & 255;
|
|
350
|
+
b = imgdata.data[j++] & 255;
|
|
351
|
+
j++;
|
|
352
|
+
gray_data[i++] = r * 11 + g * 16 + b * 5 >> 5 & 255;
|
|
353
|
+
}
|
|
354
|
+
return gray_data;
|
|
465
355
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
this.orderData += _numToHexStr(h, 2);
|
|
479
|
-
for (var i = 0; i < mono_data.length; i++) this.orderData += _numToHexStr(mono_data[i] & 0xff, 1);
|
|
356
|
+
EscPosPrinter.prototype.appendImage = function(imgdata, dither) {
|
|
357
|
+
var gray_data, mono_data;
|
|
358
|
+
var w = imgdata.width;
|
|
359
|
+
var h = imgdata.height;
|
|
360
|
+
gray_data = _convertToGray(imgdata, w, h);
|
|
361
|
+
if (dither == "diffuse") mono_data = _diffuseDither(gray_data, w, h);
|
|
362
|
+
else mono_data = _thresholdDither(gray_data, w, h);
|
|
363
|
+
w = w + 7 >> 3;
|
|
364
|
+
this.orderData += "1d763000";
|
|
365
|
+
this.orderData += _numToHexStr(w, 2);
|
|
366
|
+
this.orderData += _numToHexStr(h, 2);
|
|
367
|
+
for (var i = 0; i < mono_data.length; i++) this.orderData += _numToHexStr(mono_data[i] & 255, 1);
|
|
480
368
|
};
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
// Page Mode Commands
|
|
484
|
-
//////////////////////////////////////////////////
|
|
485
|
-
|
|
486
|
-
// Enter page mode.
|
|
487
|
-
EscPosPrinter.prototype.enterPageMode = function () {
|
|
488
|
-
this.orderData += "1b4c";
|
|
369
|
+
EscPosPrinter.prototype.enterPageMode = function() {
|
|
370
|
+
this.orderData += "1b4c";
|
|
489
371
|
};
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
this.orderData += _numToHexStr(x, 2);
|
|
497
|
-
this.orderData += _numToHexStr(y, 2);
|
|
498
|
-
this.orderData += _numToHexStr(w, 2);
|
|
499
|
-
this.orderData += _numToHexStr(h, 2);
|
|
372
|
+
EscPosPrinter.prototype.setPrintAreaInPageMode = function(x, y, w, h) {
|
|
373
|
+
this.orderData += "1b57";
|
|
374
|
+
this.orderData += _numToHexStr(x, 2);
|
|
375
|
+
this.orderData += _numToHexStr(y, 2);
|
|
376
|
+
this.orderData += _numToHexStr(w, 2);
|
|
377
|
+
this.orderData += _numToHexStr(h, 2);
|
|
500
378
|
};
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
// dir: 0:not rotated; 1:90-degree clockwise rotated;
|
|
504
|
-
// 2:180-degree clockwise rotated; 3:270-degree clockwise rotated
|
|
505
|
-
EscPosPrinter.prototype.setPrintDirectionInPageMode = function (dir) {
|
|
506
|
-
if (dir >= 0 && dir <= 3) this.orderData += "1b54" + _numToHexStr(dir, 1);
|
|
379
|
+
EscPosPrinter.prototype.setPrintDirectionInPageMode = function(dir) {
|
|
380
|
+
if (dir >= 0 && dir <= 3) this.orderData += "1b54" + _numToHexStr(dir, 1);
|
|
507
381
|
};
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
EscPosPrinter.prototype.setAbsolutePrintPositionInPageMode = function (n) {
|
|
511
|
-
if (n >= 0 && n <= 65535) this.orderData += "1d24" + _numToHexStr(n, 2);
|
|
382
|
+
EscPosPrinter.prototype.setAbsolutePrintPositionInPageMode = function(n) {
|
|
383
|
+
if (n >= 0 && n <= 65535) this.orderData += "1d24" + _numToHexStr(n, 2);
|
|
512
384
|
};
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
EscPosPrinter.prototype.setRelativePrintPositionInPageMode = function (n) {
|
|
516
|
-
if (n >= -32768 && n <= 32767) this.orderData += "1d5c" + _numToHexStr(n, 2);
|
|
385
|
+
EscPosPrinter.prototype.setRelativePrintPositionInPageMode = function(n) {
|
|
386
|
+
if (n >= -32768 && n <= 32767) this.orderData += "1d5c" + _numToHexStr(n, 2);
|
|
517
387
|
};
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
EscPosPrinter.prototype.printAndExitPageMode = function () {
|
|
521
|
-
this.orderData += "0c";
|
|
388
|
+
EscPosPrinter.prototype.printAndExitPageMode = function() {
|
|
389
|
+
this.orderData += "0c";
|
|
522
390
|
};
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
EscPosPrinter.prototype.printInPageMode = function () {
|
|
526
|
-
this.orderData += "1b0c";
|
|
391
|
+
EscPosPrinter.prototype.printInPageMode = function() {
|
|
392
|
+
this.orderData += "1b0c";
|
|
527
393
|
};
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
EscPosPrinter.prototype.clearInPageMode = function () {
|
|
531
|
-
this.orderData += "18";
|
|
394
|
+
EscPosPrinter.prototype.clearInPageMode = function() {
|
|
395
|
+
this.orderData += "18";
|
|
532
396
|
};
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
EscPosPrinter.prototype.exitPageMode = function () {
|
|
536
|
-
this.orderData += "1b53";
|
|
397
|
+
EscPosPrinter.prototype.exitPageMode = function() {
|
|
398
|
+
this.orderData += "1b53";
|
|
537
399
|
};
|
|
538
|
-
|
|
400
|
+
//#endregion
|
|
401
|
+
export { ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, columnWidthWithAlignment, EscPosPrinter as default };
|