@reportman/engine 0.0.0-stage → 0.1.0-alpha.1

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.
Files changed (244) hide show
  1. package/LICENSE +373 -0
  2. package/dist/.tsbuildinfo +1 -0
  3. package/dist/data/columns.d.ts +50 -0
  4. package/dist/data/columns.d.ts.map +1 -0
  5. package/dist/data/columns.js +385 -0
  6. package/dist/data/columns.js.map +1 -0
  7. package/dist/data/databaseinfo.d.ts +41 -0
  8. package/dist/data/databaseinfo.d.ts.map +1 -0
  9. package/dist/data/databaseinfo.js +145 -0
  10. package/dist/data/databaseinfo.js.map +1 -0
  11. package/dist/data/datainfo.d.ts +82 -0
  12. package/dist/data/datainfo.d.ts.map +1 -0
  13. package/dist/data/datainfo.js +449 -0
  14. package/dist/data/datainfo.js.map +1 -0
  15. package/dist/data/errors.d.ts +8 -0
  16. package/dist/data/errors.d.ts.map +1 -0
  17. package/dist/data/errors.js +14 -0
  18. package/dist/data/errors.js.map +1 -0
  19. package/dist/data/host.d.ts +132 -0
  20. package/dist/data/host.d.ts.map +1 -0
  21. package/dist/data/host.js +108 -0
  22. package/dist/data/host.js.map +1 -0
  23. package/dist/data/op.d.ts +21 -0
  24. package/dist/data/op.d.ts.map +1 -0
  25. package/dist/data/op.js +97 -0
  26. package/dist/data/op.js.map +1 -0
  27. package/dist/data/reportdataset.d.ts +116 -0
  28. package/dist/data/reportdataset.d.ts.map +1 -0
  29. package/dist/data/reportdataset.js +396 -0
  30. package/dist/data/reportdataset.js.map +1 -0
  31. package/dist/data/transfer.d.ts +46 -0
  32. package/dist/data/transfer.d.ts.map +1 -0
  33. package/dist/data/transfer.js +100 -0
  34. package/dist/data/transfer.js.map +1 -0
  35. package/dist/data/union.d.ts +88 -0
  36. package/dist/data/union.d.ts.map +1 -0
  37. package/dist/data/union.js +733 -0
  38. package/dist/data/union.js.map +1 -0
  39. package/dist/eval/chinesetables.d.ts +5 -0
  40. package/dist/eval/chinesetables.d.ts.map +1 -0
  41. package/dist/eval/chinesetables.js +8 -0
  42. package/dist/eval/chinesetables.js.map +1 -0
  43. package/dist/eval/evaluator.d.ts +100 -0
  44. package/dist/eval/evaluator.d.ts.map +1 -0
  45. package/dist/eval/evaluator.js +667 -0
  46. package/dist/eval/evaluator.js.map +1 -0
  47. package/dist/eval/exception.d.ts +9 -0
  48. package/dist/eval/exception.d.ts.map +1 -0
  49. package/dist/eval/exception.js +15 -0
  50. package/dist/eval/exception.js.map +1 -0
  51. package/dist/eval/fields.d.ts +60 -0
  52. package/dist/eval/fields.d.ts.map +1 -0
  53. package/dist/eval/fields.js +104 -0
  54. package/dist/eval/fields.js.map +1 -0
  55. package/dist/eval/functions.d.ts +27 -0
  56. package/dist/eval/functions.d.ts.map +1 -0
  57. package/dist/eval/functions.js +810 -0
  58. package/dist/eval/functions.js.map +1 -0
  59. package/dist/eval/identifiers.d.ts +100 -0
  60. package/dist/eval/identifiers.d.ts.map +1 -0
  61. package/dist/eval/identifiers.js +195 -0
  62. package/dist/eval/identifiers.js.map +1 -0
  63. package/dist/eval/parser.d.ts +47 -0
  64. package/dist/eval/parser.d.ts.map +1 -0
  65. package/dist/eval/parser.js +336 -0
  66. package/dist/eval/parser.js.map +1 -0
  67. package/dist/index.d.ts +52 -0
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +42 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/params/param.d.ts +92 -0
  72. package/dist/params/param.d.ts.map +1 -0
  73. package/dist/params/param.js +358 -0
  74. package/dist/params/param.js.map +1 -0
  75. package/dist/params/parameters.d.ts +87 -0
  76. package/dist/params/parameters.d.ts.map +1 -0
  77. package/dist/params/parameters.js +499 -0
  78. package/dist/params/parameters.js.map +1 -0
  79. package/dist/report/barcode/barcodeitem.d.ts +76 -0
  80. package/dist/report/barcode/barcodeitem.d.ts.map +1 -0
  81. package/dist/report/barcode/barcodeitem.js +864 -0
  82. package/dist/report/barcode/barcodeitem.js.map +1 -0
  83. package/dist/report/barcode/code128.d.ts +18 -0
  84. package/dist/report/barcode/code128.d.ts.map +1 -0
  85. package/dist/report/barcode/code128.js +187 -0
  86. package/dist/report/barcode/code128.js.map +1 -0
  87. package/dist/report/barcode/netutil.d.ts +30 -0
  88. package/dist/report/barcode/netutil.d.ts.map +1 -0
  89. package/dist/report/barcode/netutil.js +65 -0
  90. package/dist/report/barcode/netutil.js.map +1 -0
  91. package/dist/report/barcode/pdf417.d.ts +17 -0
  92. package/dist/report/barcode/pdf417.d.ts.map +1 -0
  93. package/dist/report/barcode/pdf417.js +782 -0
  94. package/dist/report/barcode/pdf417.js.map +1 -0
  95. package/dist/report/barcode/pdf417tables.d.ts +11 -0
  96. package/dist/report/barcode/pdf417tables.d.ts.map +1 -0
  97. package/dist/report/barcode/pdf417tables.js +880 -0
  98. package/dist/report/barcode/pdf417tables.js.map +1 -0
  99. package/dist/report/barcode/qrcode.d.ts +14 -0
  100. package/dist/report/barcode/qrcode.d.ts.map +1 -0
  101. package/dist/report/barcode/qrcode.js +214 -0
  102. package/dist/report/barcode/qrcode.js.map +1 -0
  103. package/dist/report/barcode/zxingwidth.d.ts +4 -0
  104. package/dist/report/barcode/zxingwidth.d.ts.map +1 -0
  105. package/dist/report/barcode/zxingwidth.js +247 -0
  106. package/dist/report/barcode/zxingwidth.js.map +1 -0
  107. package/dist/report/chart/chartidens.d.ts +70 -0
  108. package/dist/report/chart/chartidens.d.ts.map +1 -0
  109. package/dist/report/chart/chartidens.js +162 -0
  110. package/dist/report/chart/chartidens.js.map +1 -0
  111. package/dist/report/chart/chartitem.d.ts +110 -0
  112. package/dist/report/chart/chartitem.d.ts.map +1 -0
  113. package/dist/report/chart/chartitem.js +403 -0
  114. package/dist/report/chart/chartitem.js.map +1 -0
  115. package/dist/report/chart/series.d.ts +65 -0
  116. package/dist/report/chart/series.d.ts.map +1 -0
  117. package/dist/report/chart/series.js +74 -0
  118. package/dist/report/chart/series.js.map +1 -0
  119. package/dist/report/chart/vectorchart.d.ts +18 -0
  120. package/dist/report/chart/vectorchart.d.ts.map +1 -0
  121. package/dist/report/chart/vectorchart.js +356 -0
  122. package/dist/report/chart/vectorchart.js.map +1 -0
  123. package/dist/report/convert.d.ts +4 -0
  124. package/dist/report/convert.d.ts.map +1 -0
  125. package/dist/report/convert.js +162 -0
  126. package/dist/report/convert.js.map +1 -0
  127. package/dist/report/errors.d.ts +13 -0
  128. package/dist/report/errors.d.ts.map +1 -0
  129. package/dist/report/errors.js +20 -0
  130. package/dist/report/errors.js.map +1 -0
  131. package/dist/report/identifiers.d.ts +91 -0
  132. package/dist/report/identifiers.d.ts.map +1 -0
  133. package/dist/report/identifiers.js +404 -0
  134. package/dist/report/identifiers.js.map +1 -0
  135. package/dist/report/imageitem.d.ts +66 -0
  136. package/dist/report/imageitem.d.ts.map +1 -0
  137. package/dist/report/imageitem.js +190 -0
  138. package/dist/report/imageitem.js.map +1 -0
  139. package/dist/report/items.d.ts +219 -0
  140. package/dist/report/items.d.ts.map +1 -0
  141. package/dist/report/items.js +1015 -0
  142. package/dist/report/items.js.map +1 -0
  143. package/dist/report/report.d.ts +221 -0
  144. package/dist/report/report.d.ts.map +1 -0
  145. package/dist/report/report.js +1968 -0
  146. package/dist/report/report.js.map +1 -0
  147. package/dist/report/run.d.ts +87 -0
  148. package/dist/report/run.d.ts.map +1 -0
  149. package/dist/report/run.js +121 -0
  150. package/dist/report/run.js.map +1 -0
  151. package/dist/report/section.d.ts +86 -0
  152. package/dist/report/section.d.ts.map +1 -0
  153. package/dist/report/section.js +325 -0
  154. package/dist/report/section.js.map +1 -0
  155. package/dist/report/subreport.d.ts +49 -0
  156. package/dist/report/subreport.d.ts.map +1 -0
  157. package/dist/report/subreport.js +220 -0
  158. package/dist/report/subreport.js.map +1 -0
  159. package/dist/util/base64.d.ts +9 -0
  160. package/dist/util/base64.d.ts.map +1 -0
  161. package/dist/util/base64.js +60 -0
  162. package/dist/util/base64.js.map +1 -0
  163. package/dist/util/chars.d.ts +45 -0
  164. package/dist/util/chars.d.ts.map +1 -0
  165. package/dist/util/chars.js +194 -0
  166. package/dist/util/chars.js.map +1 -0
  167. package/dist/util/compositeformat.d.ts +3 -0
  168. package/dist/util/compositeformat.d.ts.map +1 -0
  169. package/dist/util/compositeformat.js +99 -0
  170. package/dist/util/compositeformat.js.map +1 -0
  171. package/dist/util/culture.d.ts +84 -0
  172. package/dist/util/culture.d.ts.map +1 -0
  173. package/dist/util/culture.js +59 -0
  174. package/dist/util/culture.js.map +1 -0
  175. package/dist/util/cultures.generated.d.ts +3 -0
  176. package/dist/util/cultures.generated.d.ts.map +1 -0
  177. package/dist/util/cultures.generated.js +1043 -0
  178. package/dist/util/cultures.generated.js.map +1 -0
  179. package/dist/util/dateformat.d.ts +21 -0
  180. package/dist/util/dateformat.d.ts.map +1 -0
  181. package/dist/util/dateformat.js +439 -0
  182. package/dist/util/dateformat.js.map +1 -0
  183. package/dist/util/dateparse.d.ts +12 -0
  184. package/dist/util/dateparse.d.ts.map +1 -0
  185. package/dist/util/dateparse.js +1212 -0
  186. package/dist/util/dateparse.js.map +1 -0
  187. package/dist/util/datetime.d.ts +70 -0
  188. package/dist/util/datetime.d.ts.map +1 -0
  189. package/dist/util/datetime.js +265 -0
  190. package/dist/util/datetime.js.map +1 -0
  191. package/dist/util/decimal.d.ts +54 -0
  192. package/dist/util/decimal.d.ts.map +1 -0
  193. package/dist/util/decimal.js +365 -0
  194. package/dist/util/decimal.js.map +1 -0
  195. package/dist/util/delphitext.d.ts +40 -0
  196. package/dist/util/delphitext.d.ts.map +1 -0
  197. package/dist/util/delphitext.js +408 -0
  198. package/dist/util/delphitext.js.map +1 -0
  199. package/dist/util/doubleutil.d.ts +30 -0
  200. package/dist/util/doubleutil.d.ts.map +1 -0
  201. package/dist/util/doubleutil.js +651 -0
  202. package/dist/util/doubleutil.js.map +1 -0
  203. package/dist/util/inflate.d.ts +7 -0
  204. package/dist/util/inflate.d.ts.map +1 -0
  205. package/dist/util/inflate.js +256 -0
  206. package/dist/util/inflate.js.map +1 -0
  207. package/dist/util/netexception.d.ts +59 -0
  208. package/dist/util/netexception.d.ts.map +1 -0
  209. package/dist/util/netexception.js +94 -0
  210. package/dist/util/netexception.js.map +1 -0
  211. package/dist/util/numberformat.d.ts +14 -0
  212. package/dist/util/numberformat.d.ts.map +1 -0
  213. package/dist/util/numberformat.js +828 -0
  214. package/dist/util/numberformat.js.map +1 -0
  215. package/dist/util/numberparse.d.ts +49 -0
  216. package/dist/util/numberparse.d.ts.map +1 -0
  217. package/dist/util/numberparse.js +568 -0
  218. package/dist/util/numberparse.js.map +1 -0
  219. package/dist/util/reportmanres.en.generated.d.ts +2 -0
  220. package/dist/util/reportmanres.en.generated.d.ts.map +1 -0
  221. package/dist/util/reportmanres.en.generated.js +2082 -0
  222. package/dist/util/reportmanres.en.generated.js.map +1 -0
  223. package/dist/util/reportmanres.es.generated.d.ts +2 -0
  224. package/dist/util/reportmanres.es.generated.d.ts.map +1 -0
  225. package/dist/util/reportmanres.es.generated.js +2082 -0
  226. package/dist/util/reportmanres.es.generated.js.map +1 -0
  227. package/dist/util/translator.d.ts +29 -0
  228. package/dist/util/translator.d.ts.map +1 -0
  229. package/dist/util/translator.js +79 -0
  230. package/dist/util/translator.js.map +1 -0
  231. package/dist/variant/coercion.d.ts +9 -0
  232. package/dist/variant/coercion.d.ts.map +1 -0
  233. package/dist/variant/coercion.js +298 -0
  234. package/dist/variant/coercion.js.map +1 -0
  235. package/dist/variant/context.d.ts +25 -0
  236. package/dist/variant/context.d.ts.map +1 -0
  237. package/dist/variant/context.js +22 -0
  238. package/dist/variant/context.js.map +1 -0
  239. package/dist/variant/variant.d.ts +193 -0
  240. package/dist/variant/variant.d.ts.map +1 -0
  241. package/dist/variant/variant.js +1229 -0
  242. package/dist/variant/variant.js.map +1 -0
  243. package/package.json +35 -4
  244. package/README.md +0 -3
@@ -0,0 +1,782 @@
1
+ // Port of Reportman.Reporting.PDF417Encoder (PDF417Encoder.cs, itself ported from the Delphi
2
+ // engine): the high level encoding of a text into PDF417 codewords (numeric, text and binary
3
+ // compaction, the escapes of the text compaction), the symbol size, the Reed-Solomon error
4
+ // correction and the drawing of the rows into the metafile, a filled rectangle per bar.
5
+ import { BrushType, MetaObjectDraw, MetaObjectType, PenType, ShapeType } from '@reportman/metafile';
6
+ import { substringNet } from '../../util/chars.js';
7
+ import { NumberStyles, tryParseInt32 } from '../../util/numberparse.js';
8
+ import { castInt32, charAt, geti, i32, idiv, imod, indexOutOfRange, mathRound, seti } from './netutil.js';
9
+ import { SPDF417_CODEWORDS, ST_MODS, ST_MODS_128, ST_MODS_256, ST_MODS_512, TEXT_COMPACTION_MODE, TEXT_COMPACTION_VALUE, } from './pdf417tables.js';
10
+ export const SPDF417_CELL_WIDTH = 17;
11
+ /** TSPDF417TextCompactionMode (flags). */
12
+ var TextMode;
13
+ (function (TextMode) {
14
+ TextMode[TextMode["None"] = 0] = "None";
15
+ TextMode[TextMode["Alpha"] = 1] = "Alpha";
16
+ TextMode[TextMode["Lower"] = 2] = "Lower";
17
+ TextMode[TextMode["Mixed"] = 4] = "Mixed";
18
+ TextMode[TextMode["Punctuation"] = 8] = "Punctuation";
19
+ })(TextMode || (TextMode = {}));
20
+ /** TStDataMode. */
21
+ var DataMode;
22
+ (function (DataMode) {
23
+ DataMode[DataMode["Binary"] = 0] = "Binary";
24
+ DataMode[DataMode["Text"] = 1] = "Text";
25
+ DataMode[DataMode["Numeric"] = 2] = "Numeric";
26
+ })(DataMode || (DataMode = {}));
27
+ /** A TSPDF417TextCompactionData of the table, with the .NET bounds check. */
28
+ function textValue(index) {
29
+ return geti(TEXT_COMPACTION_VALUE, index);
30
+ }
31
+ function textMode(index) {
32
+ return geti(TEXT_COMPACTION_MODE, index);
33
+ }
34
+ /** The error correction level: the given one, or one by the amount of data (Auto, -1). */
35
+ export function getRealErrorLevel(_numRows, _numColumns, eccLevel, numCodewords) {
36
+ if (eccLevel < 0) {
37
+ if (numCodewords < 41)
38
+ return 2;
39
+ else if (numCodewords < 161)
40
+ return 3;
41
+ else if (numCodewords < 321)
42
+ return 4;
43
+ else
44
+ return 5;
45
+ }
46
+ return eccLevel;
47
+ }
48
+ /** The count of digits from position, and whether they are worth a numeric compaction (more than 13). */
49
+ function goodForNumericCompaction(code, position, codeLen) {
50
+ let count = 0;
51
+ while (position + count < codeLen && charAt(code, position + count) >= 48 && charAt(code, position + count) <= 57)
52
+ count++;
53
+ return count > 13;
54
+ }
55
+ function isGoodTextValue(v) {
56
+ if (v > 127)
57
+ return false;
58
+ return textValue(v) >= 0;
59
+ }
60
+ function goodForTextCompaction(code, position, codeLen) {
61
+ let count = 0;
62
+ while (position + count < codeLen && isGoodTextValue(charAt(code, position + count)) && count <= 5)
63
+ count++;
64
+ if (count > 5 || (position + count >= codeLen && count > 0)) {
65
+ if (count === 1)
66
+ return false;
67
+ return true;
68
+ }
69
+ return false;
70
+ }
71
+ /** Six bytes as five base 900 digits. */
72
+ function convertBytesToBase900(s, a) {
73
+ const d = [0, 0, 0, 0, 0, 0];
74
+ for (let i = 0; i < 6; i++)
75
+ d[i] = s[i];
76
+ let sp = 0;
77
+ const digits = [0, 0, 0, 0, 0];
78
+ while (sp < 5) {
79
+ let dividend = 0;
80
+ for (let i = 0; i < 6; i++) {
81
+ dividend = dividend * 256 + d[i];
82
+ d[i] = Math.trunc(dividend / 900) & 0xff;
83
+ dividend = dividend % 900;
84
+ }
85
+ digits[sp] = dividend;
86
+ sp++;
87
+ }
88
+ let idx = 0;
89
+ while (sp > 0) {
90
+ sp--;
91
+ seti(a, idx, digits[sp]);
92
+ idx++;
93
+ }
94
+ }
95
+ function isNumericString(s) {
96
+ if (s.length === 0 || s.length > 45)
97
+ return false;
98
+ for (let i = 0; i < s.length; i++) {
99
+ const c = s.charCodeAt(i);
100
+ if (c < 48 || c > 57)
101
+ return false;
102
+ }
103
+ return true;
104
+ }
105
+ /** A string of digits as base 900 digits; returns the count. */
106
+ function convertToBase900(s, a) {
107
+ if (!isNumericString(s))
108
+ throw new Error('ConvertToBase900: S should be a numeric string');
109
+ const d = [];
110
+ for (let i = 0; i < s.length; i++)
111
+ d.push(s.charCodeAt(i));
112
+ let lenD = d.length;
113
+ let firstDigit = -1;
114
+ for (let i = lenD - 1; i >= 0; i--) {
115
+ d[i] = (d[i] - 48) & 0xffff;
116
+ if (d[i] !== 0)
117
+ firstDigit = i;
118
+ }
119
+ if (firstDigit === -1)
120
+ return 0;
121
+ let sp = 0;
122
+ const digits = new Array(45).fill(0);
123
+ let done = false;
124
+ while (!done) {
125
+ if (lenD - firstDigit <= 8) {
126
+ let dividend = 0;
127
+ for (let i = firstDigit; i < lenD; i++)
128
+ dividend = dividend * 10 + d[i];
129
+ while (dividend !== 0) {
130
+ seti(digits, sp, dividend % 900);
131
+ sp++;
132
+ dividend = Math.trunc(dividend / 900);
133
+ }
134
+ done = true;
135
+ }
136
+ else {
137
+ let rem = d[lenD - 1];
138
+ lenD--;
139
+ rem = rem + d[lenD - 1] * 10;
140
+ lenD--;
141
+ let dividend = 0;
142
+ for (let i = firstDigit; i < lenD; i++) {
143
+ dividend = dividend * 10 + d[i];
144
+ d[i] = Math.trunc(dividend / 9) & 0xffff;
145
+ dividend = dividend % 9;
146
+ }
147
+ seti(digits, sp, dividend * 100 + rem);
148
+ sp++;
149
+ if (d[firstDigit] === 0)
150
+ firstDigit++;
151
+ }
152
+ }
153
+ let idx = 0;
154
+ while (sp > 0) {
155
+ sp--;
156
+ seti(a, idx, digits[sp]);
157
+ idx++;
158
+ }
159
+ return idx;
160
+ }
161
+ /** The codewords being written (codewords, numCodewords and newTextCodeword of the C# code). */
162
+ class CodewordWriter {
163
+ codewords;
164
+ numCodewords = 1;
165
+ /** The next text value starts a codeword (two text values per codeword). */
166
+ newTextCodeword = true;
167
+ constructor(codewords) {
168
+ this.codewords = codewords;
169
+ }
170
+ /** codewords[numCodewords++] = value. */
171
+ add(value) {
172
+ seti(this.codewords, this.numCodewords, value);
173
+ this.numCodewords++;
174
+ }
175
+ /** A text value: the first half of a new codeword, or the second half of the current one. */
176
+ text(value) {
177
+ if (this.newTextCodeword) {
178
+ seti(this.codewords, this.numCodewords, 30 * value);
179
+ this.newTextCodeword = false;
180
+ }
181
+ else {
182
+ const i = this.numCodewords;
183
+ this.numCodewords++;
184
+ seti(this.codewords, i, geti(this.codewords, i) + value);
185
+ this.newTextCodeword = true;
186
+ }
187
+ }
188
+ }
189
+ /** The codewords of a text: the first one (the length) is left for GenerateCodewords. */
190
+ function textToCodewords(code, codewords, nfi) {
191
+ for (let i = 0; i <= 2700; i++)
192
+ seti(codewords, i, 900); // PadCodeword
193
+ const w = new CodewordWriter(codewords);
194
+ const pos = { value: 0 };
195
+ const codeLen = code.length;
196
+ if (codeLen === 0)
197
+ return w.numCodewords;
198
+ let currentMode;
199
+ if (goodForNumericCompaction(code, pos.value, codeLen)) {
200
+ currentMode = DataMode.Numeric;
201
+ w.add(902); // NumericCompaction
202
+ }
203
+ else if (goodForTextCompaction(code, pos.value, codeLen)) {
204
+ currentMode = DataMode.Text;
205
+ }
206
+ else {
207
+ currentMode = DataMode.Binary;
208
+ w.add(901); // BinaryCompaction
209
+ }
210
+ w.newTextCodeword = true;
211
+ while (pos.value < codeLen) {
212
+ const before = pos.value;
213
+ switch (currentMode) {
214
+ case DataMode.Binary:
215
+ encodeBinary(code, w, pos, codeLen);
216
+ break;
217
+ case DataMode.Text:
218
+ encodeText(code, w, pos, codeLen, nfi);
219
+ break;
220
+ case DataMode.Numeric:
221
+ encodeNumeric(code, w, pos, codeLen);
222
+ break;
223
+ }
224
+ if (goodForNumericCompaction(code, pos.value, codeLen)) {
225
+ if (currentMode !== DataMode.Numeric) {
226
+ currentMode = DataMode.Numeric;
227
+ w.add(902);
228
+ }
229
+ }
230
+ else if (goodForTextCompaction(code, pos.value, codeLen)) {
231
+ if (currentMode !== DataMode.Text) {
232
+ w.add(900); // TextCompaction
233
+ currentMode = DataMode.Text;
234
+ w.newTextCodeword = true;
235
+ }
236
+ else if (pos.value === before) {
237
+ // C# parity: the text compaction stops at a character it cannot write (an escape of a
238
+ // value above 127 or without a text value, \G...), and this loop calls it again at the
239
+ // same position for ever: the C# engine never finishes this barcode.
240
+ throw new Error('PDF417: the text compaction cannot write the escape at position ' +
241
+ String(before) +
242
+ ' of the text (the C# engine loops for ever on it)');
243
+ }
244
+ }
245
+ else {
246
+ if (currentMode !== DataMode.Binary) {
247
+ w.add(901);
248
+ currentMode = DataMode.Binary;
249
+ }
250
+ }
251
+ }
252
+ return w.numCodewords;
253
+ }
254
+ function countBytes(code, position, codeLen) {
255
+ let result = 0;
256
+ let done = false;
257
+ while (!done) {
258
+ // C# parity: the count goes one past the end of the text (<=): binary data that ends the text
259
+ // reads past its end (IndexOutOfRangeException)
260
+ if (result + position <= codeLen &&
261
+ !goodForNumericCompaction(code, position + result, codeLen) &&
262
+ !goodForTextCompaction(code, position + result, codeLen))
263
+ result++;
264
+ else
265
+ done = true;
266
+ }
267
+ return result;
268
+ }
269
+ function encodeBinary(code, w, pos, codeLen) {
270
+ const position = pos.value;
271
+ const binaryDataSize = countBytes(code, position, codeLen);
272
+ const multipleOfSix = binaryDataSize % 6 === 0;
273
+ if (multipleOfSix)
274
+ w.add(924);
275
+ else
276
+ w.add(901);
277
+ let i = 0;
278
+ const a = [0, 0, 0, 0, 0, 0, 0];
279
+ while (i < binaryDataSize) {
280
+ if (binaryDataSize - i < 6) {
281
+ w.add(charAt(code, position + i) & 0xff);
282
+ i++;
283
+ }
284
+ else {
285
+ const bytes = [0, 1, 2, 3, 4, 5].map((k) => charAt(code, position + i + k) & 0xff);
286
+ convertBytesToBase900(bytes, a);
287
+ for (let j = 0; j < 5; j++)
288
+ w.add(a[j]);
289
+ i += 6;
290
+ }
291
+ }
292
+ pos.value = position + binaryDataSize;
293
+ }
294
+ function collectDigits(code, pos, codeLen) {
295
+ const startPos = pos.value;
296
+ const maxDigitChunk = 38;
297
+ while (pos.value < codeLen && pos.value - startPos < maxDigitChunk && charAt(code, pos.value) >= 48 && charAt(code, pos.value) <= 57)
298
+ pos.value++;
299
+ if (pos.value - startPos > 0)
300
+ return '1' + code.substring(startPos, pos.value);
301
+ return '';
302
+ }
303
+ function encodeNumeric(code, w, pos, codeLen) {
304
+ let numericString;
305
+ const a = new Array(45).fill(0);
306
+ do {
307
+ numericString = collectDigits(code, pos, codeLen);
308
+ if (numericString !== '') {
309
+ const lenA = convertToBase900(numericString, a);
310
+ for (let i = 0; i < lenA; i++)
311
+ w.add(a[i]);
312
+ }
313
+ } while (numericString !== '');
314
+ }
315
+ function selectBestTextMode(mode) {
316
+ if ((mode & TextMode.Alpha) !== 0)
317
+ return TextMode.Alpha;
318
+ if ((mode & TextMode.Lower) !== 0)
319
+ return TextMode.Lower;
320
+ if ((mode & TextMode.Mixed) !== 0)
321
+ return TextMode.Mixed;
322
+ if ((mode & TextMode.Punctuation) !== 0)
323
+ return TextMode.Punctuation;
324
+ return TextMode.None;
325
+ }
326
+ const LatchAlphaToLower = 27;
327
+ const LatchAlphaToMixed = 28;
328
+ const ShiftAlphaToPunctuation = 29;
329
+ const ShiftLowerToAlpha = 27;
330
+ const LatchLowerToMixed = 28;
331
+ const ShiftLowerToPunctuation = 29;
332
+ const LatchMixedToPunctuation = 25;
333
+ const LatchMixedToLower = 27;
334
+ const LatchMixedToAlpha = 28;
335
+ const ShiftMixedToPunctuation = 29;
336
+ const LatchPunctuationToAlpha = 29;
337
+ /** Writes the latch or shift from one text submode to another; returns the new submode. */
338
+ function changeTextSubmode(currentMode, newMode, useShift, w) {
339
+ let result = useShift ? currentMode : newMode;
340
+ switch (currentMode) {
341
+ case TextMode.Alpha:
342
+ if (newMode === TextMode.Lower) {
343
+ w.text(LatchAlphaToLower);
344
+ if (useShift)
345
+ result = newMode;
346
+ }
347
+ else if (newMode === TextMode.Mixed) {
348
+ w.text(LatchAlphaToMixed);
349
+ if (useShift)
350
+ result = newMode;
351
+ }
352
+ else if (newMode === TextMode.Punctuation) {
353
+ if (useShift)
354
+ w.text(ShiftAlphaToPunctuation);
355
+ else {
356
+ w.text(LatchAlphaToMixed);
357
+ w.text(LatchMixedToPunctuation);
358
+ }
359
+ }
360
+ break;
361
+ case TextMode.Lower:
362
+ if (newMode === TextMode.Alpha) {
363
+ if (useShift)
364
+ w.text(ShiftLowerToAlpha);
365
+ else {
366
+ w.text(LatchLowerToMixed);
367
+ w.text(LatchMixedToAlpha);
368
+ }
369
+ }
370
+ else if (newMode === TextMode.Mixed) {
371
+ w.text(LatchLowerToMixed);
372
+ if (useShift)
373
+ result = newMode;
374
+ }
375
+ else if (newMode === TextMode.Punctuation) {
376
+ if (useShift)
377
+ w.text(ShiftLowerToPunctuation);
378
+ else {
379
+ w.text(LatchLowerToMixed);
380
+ w.text(LatchMixedToPunctuation);
381
+ }
382
+ }
383
+ break;
384
+ case TextMode.Mixed:
385
+ if (newMode === TextMode.Alpha) {
386
+ w.text(LatchMixedToAlpha);
387
+ if (useShift)
388
+ result = newMode;
389
+ }
390
+ else if (newMode === TextMode.Lower) {
391
+ w.text(LatchMixedToLower);
392
+ if (useShift)
393
+ result = newMode;
394
+ }
395
+ else if (newMode === TextMode.Punctuation) {
396
+ if (useShift)
397
+ w.text(ShiftMixedToPunctuation);
398
+ else
399
+ w.text(LatchMixedToPunctuation);
400
+ }
401
+ break;
402
+ case TextMode.Punctuation:
403
+ if (newMode === TextMode.Alpha) {
404
+ w.text(LatchPunctuationToAlpha);
405
+ if (useShift)
406
+ result = newMode;
407
+ }
408
+ else if (newMode === TextMode.Lower) {
409
+ w.text(LatchPunctuationToAlpha);
410
+ w.text(LatchAlphaToLower);
411
+ if (useShift)
412
+ result = newMode;
413
+ }
414
+ else if (newMode === TextMode.Mixed) {
415
+ w.text(LatchPunctuationToAlpha);
416
+ w.text(LatchAlphaToMixed);
417
+ if (useShift)
418
+ result = newMode;
419
+ }
420
+ break;
421
+ }
422
+ return result;
423
+ }
424
+ /** int.TryParse(s, NumberStyles.HexNumber, null): white space around up to eight hex digits. */
425
+ function tryParseHex(s) {
426
+ const isWhite = (c) => c === 0x20 || (c >= 0x09 && c <= 0x0d);
427
+ let i = 0;
428
+ while (i < s.length && isWhite(s.charCodeAt(i)))
429
+ i++;
430
+ let value = 0;
431
+ let digits = 0;
432
+ let significant = 0;
433
+ for (; i < s.length; i++) {
434
+ const c = s.charCodeAt(i);
435
+ const h = c >= 48 && c <= 57 ? c - 48 : c >= 65 && c <= 70 ? c - 55 : c >= 97 && c <= 102 ? c - 87 : -1;
436
+ if (h < 0)
437
+ break;
438
+ digits++;
439
+ if (significant > 0 || h !== 0)
440
+ significant++;
441
+ value = value * 16 + h;
442
+ }
443
+ if (digits === 0 || significant > 8)
444
+ return undefined;
445
+ while (i < s.length && isWhite(s.charCodeAt(i)))
446
+ i++;
447
+ for (; i < s.length; i++)
448
+ if (s.charCodeAt(i) !== 0)
449
+ return undefined;
450
+ return value | 0;
451
+ }
452
+ /** The next character of the text compaction, with the escapes \ddd, \Cddd, \Xhh and \\. */
453
+ function getNextCharacter(code, next, pos, codeLen, nfi) {
454
+ next.newChar = 0;
455
+ next.codeword = false;
456
+ const position = pos.value;
457
+ if (position < codeLen) {
458
+ if (charAt(code, position) === 92 && position + 1 < codeLen) {
459
+ const nc = charAt(code, position + 1);
460
+ if (nc >= 48 && nc <= 57) {
461
+ const v = tryParseInt32(substringNet(code, position + 1, Math.min(3, codeLen - position - 1)), NumberStyles.Integer, nfi);
462
+ next.newChar = v ?? 0;
463
+ pos.value += 4;
464
+ }
465
+ else if (nc === 67 || nc === 99) {
466
+ next.codeword = true;
467
+ const v = tryParseInt32(substringNet(code, position + 2, Math.min(3, codeLen - position - 2)), NumberStyles.Integer, nfi);
468
+ next.newChar = v ?? 0;
469
+ pos.value += 5;
470
+ }
471
+ else if (nc === 71 || nc === 103) {
472
+ // C# parity: the number is parsed from the G itself, so it never parses: no character is read
473
+ const v = tryParseInt32(substringNet(code, position + 1, Math.min(6, codeLen - position - 1)), NumberStyles.Integer, nfi);
474
+ if (v !== undefined) {
475
+ pos.value += 8;
476
+ next.codeword = true;
477
+ next.newChar = v;
478
+ }
479
+ }
480
+ else if (nc === 88 || nc === 120) {
481
+ const v = tryParseHex(substringNet(code, position + 2, 2));
482
+ next.newChar = v ?? 0;
483
+ pos.value += 4;
484
+ }
485
+ else if (nc === 92) {
486
+ next.newChar = charAt(code, position);
487
+ pos.value += 2;
488
+ }
489
+ else {
490
+ next.newChar = charAt(code, position);
491
+ pos.value++;
492
+ }
493
+ }
494
+ else {
495
+ next.newChar = charAt(code, position);
496
+ pos.value++;
497
+ }
498
+ }
499
+ }
500
+ function encodeText(code, w, pos, codeLen, nfi) {
501
+ let currentTextSubmode = TextMode.Alpha;
502
+ let curValue = -1;
503
+ let curMode = TextMode.None;
504
+ let done = false;
505
+ const next = { newChar: 0, codeword: false };
506
+ while (pos.value < codeLen && !done) {
507
+ const oldPosition = pos.value;
508
+ getNextCharacter(code, next, pos, codeLen, nfi);
509
+ const newChar = next.newChar;
510
+ const isCodeword = next.codeword;
511
+ let validtext = false;
512
+ if (newChar <= 127)
513
+ validtext = textValue(newChar) >= 0;
514
+ if (!validtext && !isCodeword) {
515
+ pos.value = oldPosition;
516
+ break;
517
+ }
518
+ else if (!isCodeword) {
519
+ curValue = textValue(newChar);
520
+ curMode = textMode(newChar);
521
+ }
522
+ if (isCodeword) {
523
+ if (!w.newTextCodeword)
524
+ w.text(29);
525
+ w.newTextCodeword = true;
526
+ w.add(newChar);
527
+ }
528
+ else {
529
+ if ((currentTextSubmode & curMode) === 0) {
530
+ let useShift = true;
531
+ if (pos.value < codeLen) {
532
+ const nextCode = charAt(code, pos.value);
533
+ if (nextCode <= 127 && (currentTextSubmode & textMode(nextCode)) === 0)
534
+ useShift = false;
535
+ }
536
+ currentTextSubmode = changeTextSubmode(currentTextSubmode, selectBestTextMode(curMode), useShift, w);
537
+ }
538
+ w.text(curValue);
539
+ }
540
+ if (goodForNumericCompaction(code, pos.value, codeLen))
541
+ done = true;
542
+ }
543
+ if (!w.newTextCodeword)
544
+ w.text(29);
545
+ }
546
+ /** CalculateSize: the columns (xSize) and rows (ySize) of the symbol. */
547
+ function calculateSize(numCodewords, errorLevel, inNumRows, inNumCols) {
548
+ const numErrorCodewords = castInt32(Math.pow(2, errorLevel + 1));
549
+ let xSize = inNumCols;
550
+ let ySize = inNumRows;
551
+ if (inNumRows <= 0 || inNumCols <= 0) {
552
+ if (inNumRows > 0) {
553
+ let i = 1;
554
+ while (i <= 30) {
555
+ if (i32(Math.imul(i, inNumRows) - numErrorCodewords) > numCodewords)
556
+ break;
557
+ i++;
558
+ }
559
+ xSize = i;
560
+ }
561
+ else if (inNumCols > 0) {
562
+ let i = 3;
563
+ while (i <= 90) {
564
+ if (i32(Math.imul(i, inNumCols) - numErrorCodewords) > numCodewords)
565
+ break;
566
+ i++;
567
+ }
568
+ ySize = i;
569
+ }
570
+ else {
571
+ let i = 1;
572
+ let j = 3;
573
+ while (i32(i * j - numErrorCodewords) < numCodewords) {
574
+ if (j < 90)
575
+ j++;
576
+ if (i < 30 && i32(i * j - numErrorCodewords) < numCodewords)
577
+ i++;
578
+ if (j >= 90 && i >= 30)
579
+ break;
580
+ }
581
+ xSize = i;
582
+ ySize = j;
583
+ }
584
+ }
585
+ return { xSize, ySize };
586
+ }
587
+ /** The Reed-Solomon error correction codewords of codewords[0..numCodewords). */
588
+ function calculateECC(codewords, numCodewords, eccLen) {
589
+ const baseReg = new Array(800).fill(0);
590
+ const coeffReg = new Array(800).fill(0);
591
+ if (eccLen < 128) {
592
+ const row = ST_MODS[eccLen];
593
+ if (row === undefined && eccLen > 0)
594
+ throw indexOutOfRange();
595
+ for (let i = 0; i < eccLen; i++)
596
+ seti(coeffReg, i, geti(row, i));
597
+ }
598
+ else if (eccLen === 128) {
599
+ for (let i = 0; i < eccLen; i++)
600
+ seti(coeffReg, i, geti(ST_MODS_128, i));
601
+ }
602
+ else if (eccLen === 256) {
603
+ for (let i = 0; i < eccLen; i++)
604
+ seti(coeffReg, i, geti(ST_MODS_256, i));
605
+ }
606
+ else if (eccLen === 512) {
607
+ for (let i = 0; i < eccLen; i++)
608
+ seti(coeffReg, i, geti(ST_MODS_512, i));
609
+ }
610
+ for (let i = 0; i < eccLen; i++)
611
+ seti(baseReg, i, 0);
612
+ for (let i = numCodewords; i < i32(numCodewords + eccLen); i++)
613
+ seti(codewords, i, 0);
614
+ for (let i = 0; i < numCodewords; i++) {
615
+ const wrap = (geti(baseReg, eccLen - 1) + geti(codewords, i)) % 929;
616
+ for (let j = eccLen - 1; j >= 1; j--) {
617
+ let temp = (geti(coeffReg, eccLen - 1 - j) * wrap) % 929;
618
+ temp = (929 - temp) % 929;
619
+ seti(baseReg, j, (geti(baseReg, j - 1) + temp) % 929);
620
+ }
621
+ let temp0 = (geti(coeffReg, eccLen - 1) * wrap) % 929;
622
+ temp0 = (929 - temp0) % 929;
623
+ seti(baseReg, 0, temp0);
624
+ }
625
+ for (let j = 0; j < eccLen; j++)
626
+ seti(baseReg, j, (929 - geti(baseReg, j)) % 929);
627
+ for (let j = 0; j < eccLen; j++)
628
+ seti(codewords, numCodewords + j, geti(baseReg, eccLen - 1 - j));
629
+ }
630
+ export function generateCodewords(text, eccLevelIn, numRowsIn, numColsIn, nfi) {
631
+ const codewords = new Array(2701).fill(0);
632
+ const numCodewords = textToCodewords(text, codewords, nfi);
633
+ const errorLevel = getRealErrorLevel(numRowsIn, numColsIn, eccLevelIn, numCodewords);
634
+ const numErrorCodewords = castInt32(Math.pow(2, errorLevel + 1));
635
+ const { xSize, ySize } = calculateSize(numCodewords, errorLevel, numRowsIn, numColsIn);
636
+ const cells = Math.imul(xSize, ySize);
637
+ const padded = i32(numCodewords + i32(i32(cells - numCodewords) - numErrorCodewords));
638
+ if (padded < 0)
639
+ throw new Error('Barcode code too large');
640
+ seti(codewords, 0, padded);
641
+ if (i32(numErrorCodewords + numCodewords) <= cells)
642
+ calculateECC(codewords, i32(cells - numErrorCodewords), numErrorCodewords);
643
+ else
644
+ throw new Error('Barcode code too large');
645
+ return { codewords, xSize, ySize, numCodewords, numErrorCodewords };
646
+ }
647
+ function codewordToBitmask(rowNumber, codeword) {
648
+ if (codeword < 0 || codeword > 929)
649
+ throw new Error('Invalid codeword');
650
+ return geti(SPDF417_CODEWORDS[imod(rowNumber, 3)], codeword);
651
+ }
652
+ function columnPosition(colNumber, modul) {
653
+ return Math.imul(Math.imul(colNumber, SPDF417_CELL_WIDTH), modul);
654
+ }
655
+ /** A bar: the rectangle from a to c, rotated around the origin (its corners, not its bounds). */
656
+ function drawBar(cv, a, c) {
657
+ const alpha = ((cv.rotation / 10.0) * Math.PI) / 180.0;
658
+ const sinus = Math.sin(alpha);
659
+ const cosinus = Math.cos(alpha);
660
+ const ta = {
661
+ x: i32(cv.fLeft + castInt32(mathRound(a.x * cosinus + a.y * sinus))),
662
+ y: i32(cv.fTop + castInt32(mathRound(-a.x * sinus + a.y * cosinus))),
663
+ };
664
+ const tc = {
665
+ x: i32(cv.fLeft + castInt32(mathRound(c.x * cosinus + c.y * sinus))),
666
+ y: i32(cv.fTop + castInt32(mathRound(-c.x * sinus + c.y * cosinus))),
667
+ };
668
+ const metaobj = new MetaObjectDraw();
669
+ metaobj.metaType = MetaObjectType.Draw;
670
+ metaobj.top = ta.y;
671
+ metaobj.left = ta.x;
672
+ // C# parity: the width and height of a rotated bar are those of its rotated diagonal (they
673
+ // may be negative)
674
+ metaobj.width = i32(tc.x - ta.x);
675
+ metaobj.height = i32(tc.y - ta.y);
676
+ metaobj.drawStyle = ShapeType.Rectangle;
677
+ metaobj.brushStyle = BrushType.Solid;
678
+ // C# parity: the PDF417 bars are stroked too (PenType.Solid), unlike the 1D bars and the QR
679
+ metaobj.penStyle = PenType.Solid;
680
+ metaobj.penWidth = 0;
681
+ metaobj.penColor = cv.bColor;
682
+ metaobj.brushColor = cv.bColor;
683
+ cv.meta.pages.get(cv.meta.currentPage).objects.push(metaobj);
684
+ }
685
+ function drawCodewordBitmask(cv, rowNumber, colNumber, workBarHeight, bitmask) {
686
+ const modul = cv.modul;
687
+ for (let i = 16; i >= 0; i--) {
688
+ if (((bitmask >>> i) & 1) !== 0) {
689
+ const aleft = i32(Math.imul(16 - i, modul) + columnPosition(colNumber, modul));
690
+ const atop = Math.imul(rowNumber, workBarHeight);
691
+ const awidth = modul;
692
+ const aheight = i32(workBarHeight + 1);
693
+ drawBar(cv, { x: aleft, y: atop }, { x: i32(aleft + awidth), y: i32(atop + aheight) });
694
+ }
695
+ }
696
+ }
697
+ function drawCodeword(cv, rowNumber, colNumber, workBarHeight, pattern) {
698
+ const modul = cv.modul;
699
+ let curPos = 0;
700
+ let drawBlock = true;
701
+ for (let i = 0; i < pattern.length; i++) {
702
+ const newPos = Math.imul(pattern.charCodeAt(i) - 48, modul);
703
+ if (drawBlock) {
704
+ const aleft = i32(curPos + columnPosition(colNumber, modul));
705
+ const atop = Math.imul(rowNumber, workBarHeight);
706
+ const awidth = newPos;
707
+ const aheight = i32(workBarHeight + 1);
708
+ drawBar(cv, { x: aleft, y: atop }, { x: i32(aleft + awidth), y: i32(atop + aheight) });
709
+ }
710
+ curPos = i32(curPos + newPos);
711
+ drawBlock = !drawBlock;
712
+ }
713
+ }
714
+ function drawStartPattern(cv, rowNumber, workBarHeight) {
715
+ drawCodeword(cv, rowNumber, 0, workBarHeight, '81111113');
716
+ }
717
+ function drawStopPattern(cv, rowNumber, colNumber, workBarHeight, truncated) {
718
+ if (truncated)
719
+ drawCodeword(cv, rowNumber, colNumber, workBarHeight, '1');
720
+ else
721
+ drawCodeword(cv, rowNumber, colNumber, workBarHeight, '711311121');
722
+ }
723
+ function drawLeftRowIndicator(cv, rowNumber, workBarHeight, numRows, numCols, errorLevel) {
724
+ let codeword = 0;
725
+ const base = Math.imul(idiv(rowNumber, 3), 30);
726
+ if (imod(rowNumber, 3) === 0)
727
+ codeword = i32(base + idiv(numRows - 1, 3));
728
+ else if (imod(rowNumber, 3) === 1)
729
+ codeword = i32(base + imod(numRows - 1, 3) + Math.imul(3, errorLevel));
730
+ else if (imod(rowNumber, 3) === 2)
731
+ codeword = i32(base + (numCols - 1));
732
+ drawCodewordBitmask(cv, rowNumber, 1, workBarHeight, codewordToBitmask(rowNumber, codeword));
733
+ }
734
+ function drawRightRowIndicator(cv, rowNumber, colNumber, workBarHeight, numRows, numCols, errorLevel) {
735
+ let codeword = 0;
736
+ const base = Math.imul(idiv(rowNumber, 3), 30);
737
+ if (imod(rowNumber, 3) === 0)
738
+ codeword = i32(base + (numCols - 1));
739
+ else if (imod(rowNumber, 3) === 1)
740
+ codeword = i32(base + idiv(numRows - 1, 3));
741
+ else if (imod(rowNumber, 3) === 2)
742
+ codeword = i32(base + imod(numRows - 1, 3) + Math.imul(3, errorLevel));
743
+ drawCodewordBitmask(cv, rowNumber, colNumber, workBarHeight, codewordToBitmask(rowNumber, codeword));
744
+ }
745
+ /** Draw2DBarcode: the PDF417 symbol of a text into the current page of the metafile. */
746
+ export function draw2DBarcode(currentText, eccLevel, numRows, numColumns, truncated, modul, fLeft, fTop, height, meta, bColor, rotation, nfi) {
747
+ const { codewords, xSize, ySize, numCodewords, numErrorCodewords } = generateCodewords(currentText, eccLevel, numRows, numColumns, nfi);
748
+ const cv = { meta, fLeft, fTop, modul, bColor, rotation };
749
+ let codewordPos = 1;
750
+ const workBarHeight = idiv(height, ySize);
751
+ const errorLevel = getRealErrorLevel(numRows, numColumns, eccLevel, numCodewords);
752
+ const cells = Math.imul(xSize, ySize);
753
+ for (let i = 0; i < ySize; i++) {
754
+ drawStartPattern(cv, i, workBarHeight);
755
+ drawLeftRowIndicator(cv, i, workBarHeight, ySize, xSize, errorLevel);
756
+ for (let j = 0; j < xSize; j++) {
757
+ if (i === 0 && j === 0) {
758
+ drawCodewordBitmask(cv, i, j + 2, workBarHeight, codewordToBitmask(i, geti(codewords, 0)));
759
+ }
760
+ else if (codewordPos < numCodewords) {
761
+ drawCodewordBitmask(cv, i, j + 2, workBarHeight, codewordToBitmask(i, geti(codewords, codewordPos)));
762
+ codewordPos++;
763
+ }
764
+ else if (codewordPos >= i32(cells - numErrorCodewords)) {
765
+ drawCodewordBitmask(cv, i, j + 2, workBarHeight, codewordToBitmask(i, geti(codewords, codewordPos)));
766
+ codewordPos++;
767
+ }
768
+ else {
769
+ drawCodewordBitmask(cv, i, j + 2, workBarHeight, codewordToBitmask(i, 900));
770
+ codewordPos++;
771
+ }
772
+ }
773
+ if (truncated) {
774
+ drawStopPattern(cv, i, xSize + 2, workBarHeight, true);
775
+ }
776
+ else {
777
+ drawRightRowIndicator(cv, i, xSize + 2, workBarHeight, ySize, xSize, errorLevel);
778
+ drawStopPattern(cv, i, xSize + 3, workBarHeight, false);
779
+ }
780
+ }
781
+ }
782
+ //# sourceMappingURL=pdf417.js.map