|
307 | 307 | let font = 'fonta';
|
308 | 308 | let align = 'left';
|
309 | 309 |
|
| 310 | + let barcode = {}; |
| 311 | + let qrcode = {}; |
| 312 | + let pdf417 = {}; |
| 313 | + |
310 | 314 | result += `<div class="receipt" style="--columns: ${columns};">`;
|
311 | 315 |
|
312 | 316 | for (let line of data) {
|
|
339 | 343 | }
|
340 | 344 | }
|
341 | 345 |
|
342 |
| - if (command.type === 'qrcode' && command.command === 'print') { |
343 |
| - result += `<div class='placeholder ${command.type} ${align}'><img src='https://bwipjs-api.metafloor.com/?bcid=qrcode&text=${command.value}' onerror="this.style.display='none'"></div>`; |
| 346 | + if (command.type === 'qrcode') { |
| 347 | + |
| 348 | + if (command.property) { |
| 349 | + qrcode[command.property] = command.value; |
| 350 | + } |
| 351 | + |
| 352 | + if (command.command === 'print') { |
| 353 | + let properties = { |
| 354 | + bcid: 'qrcode', |
| 355 | + text: qrcode.data, |
| 356 | + eclevel: qrcode.errorlevel.toUpperCase(), |
| 357 | + scale: qrcode.size, |
| 358 | + } |
| 359 | + |
| 360 | + result += `<div class='placeholder ${command.type} ${align}'><img src='https://bwipjs-api.metafloor.com/?${Object.entries(properties).map(i => i[0]+'='+escape(i[1])).join('&')}' onerror="this.style.display='none'"></div>`; |
| 361 | + |
| 362 | + qrcode = {}; |
| 363 | + } |
344 | 364 | }
|
345 | 365 |
|
346 |
| - if (command.type === 'pdf417' && command.command === 'print') { |
347 |
| - result += `<div class='placeholder ${command.type} ${align}'><img src='https://bwipjs-api.metafloor.com/?bcid=pdf417&text=${command.value}' onerror="this.style.display='none'"></div>`; |
| 366 | + if (command.type === 'pdf417') { |
| 367 | + if (command.property) { |
| 368 | + pdf417[command.property] = command.value; |
| 369 | + } |
| 370 | + |
| 371 | + if (command.command === 'print') { |
| 372 | + let properties = { |
| 373 | + bcid: 'pdf417', |
| 374 | + text: pdf417.data, |
| 375 | + eclevel: pdf417.errorlevel, |
| 376 | + rows: pdf417.rows, |
| 377 | + columns: pdf417.columns, |
| 378 | + scale: pdf417.width * 2, |
| 379 | + } |
| 380 | + |
| 381 | + result += `<div class='placeholder ${command.type} ${align}'><img src='https://bwipjs-api.metafloor.com/?${Object.entries(properties).map(i => i[0]+'='+escape(i[1])).join('&')}' onerror="this.style.display='none'"></div>`; |
| 382 | + |
| 383 | + pdf417 = {}; |
| 384 | + } |
348 | 385 | }
|
349 | 386 |
|
350 |
| - if (command.type === 'barcode' && ! command.property) { |
351 |
| - let symbologies = { |
352 |
| - 'upca': 'upca', |
353 |
| - 'upce': 'upce', |
354 |
| - 'ean13': 'ean13', |
355 |
| - 'ean8': 'ean8', |
356 |
| - 'code39': 'code39', |
357 |
| - 'coda39': 'code39', |
358 |
| - 'itf': 'interleaved2of5', |
359 |
| - 'interleaved-2-of-5': 'interleaved2of5', |
360 |
| - 'nw-7': 'rationalizedCodabar', |
361 |
| - 'codabar': 'rationalizedCodabar', |
362 |
| - 'code93': 'code93', |
363 |
| - 'code128': 'code128', |
364 |
| - 'gs1-128': 'gs1-128', |
365 |
| - 'gs1-databar-omni': 'databaromni', |
366 |
| - 'gs1-databar-truncated': 'databartruncated', |
367 |
| - 'gs1-databar-limited': 'databarlimited', |
368 |
| - 'gs1-databar-expanded': 'databarexpanded', |
369 |
| - 'code128-auto': 'code128', |
| 387 | + if (command.type === 'barcode') { |
| 388 | + if (command.property) { |
| 389 | + barcode[command.property] = command.value; |
370 | 390 | }
|
| 391 | + |
| 392 | + else { |
| 393 | + if (command.value) { |
| 394 | + for (let key in command.value) { |
| 395 | + barcode[key] = command.value[key]; |
| 396 | + } |
| 397 | + } |
| 398 | + |
| 399 | + let symbologies = { |
| 400 | + 'upca': 'upca', |
| 401 | + 'upce': 'upce', |
| 402 | + 'ean13': 'ean13', |
| 403 | + 'ean8': 'ean8', |
| 404 | + 'code39': 'code39', |
| 405 | + 'coda39': 'code39', |
| 406 | + 'itf': 'interleaved2of5', |
| 407 | + 'interleaved-2-of-5': 'interleaved2of5', |
| 408 | + 'nw-7': 'rationalizedCodabar', |
| 409 | + 'codabar': 'rationalizedCodabar', |
| 410 | + 'code93': 'code93', |
| 411 | + 'code128': 'code128', |
| 412 | + 'gs1-128': 'gs1-128', |
| 413 | + 'gs1-databar-omni': 'databaromni', |
| 414 | + 'gs1-databar-truncated': 'databartruncated', |
| 415 | + 'gs1-databar-limited': 'databarlimited', |
| 416 | + 'gs1-databar-expanded': 'databarexpanded', |
| 417 | + 'code128-auto': 'code128', |
| 418 | + } |
| 419 | + |
| 420 | + let properties = { |
| 421 | + bcid: symbologies[barcode.symbology], |
| 422 | + text: barcode.data, |
| 423 | + height: (barcode.height / barcode.width) / 4, |
| 424 | + scale: barcode.width, |
| 425 | + } |
| 426 | + |
| 427 | + if (barcode.text) { |
| 428 | + properties.includetext = 'true'; |
| 429 | + properties.textsize = 8; |
| 430 | + } |
| 431 | + |
| 432 | + result += `<div class='placeholder ${command.type} ${align}'><img src='https://bwipjs-api.metafloor.com/?${Object.entries(properties).map(i => i[0]+'='+escape(i[1])).join('&')}' onerror="this.style.display='none'"></div>`; |
371 | 433 |
|
372 |
| - result += `<div class='placeholder ${command.type} ${align}'><img src='https://bwipjs-api.metafloor.com/?bcid=${symbologies[command.value.symbology]}&text=${command.value.data}' onerror="this.style.display='none'"></div>`; |
| 434 | + barcode = {}; |
| 435 | + } |
373 | 436 | }
|
374 | 437 |
|
375 | 438 | if (command.type === 'image') {
|
|
708 | 771 | overflow: scroll;
|
709 | 772 | }
|
710 | 773 |
|
711 |
| - #errors { |
712 |
| - } |
713 |
| - |
714 | 774 | #errors .error {
|
715 | 775 | background: #f0f0f0;
|
716 | 776 | border-radius: 6px;
|
|
813 | 873 |
|
814 | 874 | #output[data-format="text"] .placeholder {
|
815 | 875 | width: 100%;
|
| 876 | + overflow-x: hidden; |
816 | 877 | }
|
817 | 878 | #output[data-format="text"] .placeholder * {
|
818 | 879 | display: block;
|
819 |
| - width: calc(var(--width-a) * 24); |
820 |
| - height: calc(var(--height-a) * 4); |
821 |
| - } |
822 |
| - #output[data-format="text"] .placeholder div { |
823 |
| - background: #ddd; |
824 |
| - width: calc(var(--width-a) * 24); |
825 |
| - height: calc(var(--height-a) * 4); |
826 |
| - display: flex; |
827 |
| - flex-shrink: 0; |
828 |
| - align-items: center; |
829 |
| - justify-content: center; |
830 |
| - font-size: 8px; |
831 | 880 | }
|
832 | 881 | #output[data-format="text"] .placeholder.qrcode * {
|
833 |
| - width: calc(var(--width-a) * 16); |
834 |
| - height: calc(var(--width-a) * 16); |
| 882 | + zoom: 33%; |
835 | 883 | }
|
836 | 884 | #output[data-format="text"] .placeholder.pdf417 * {
|
837 |
| - height: calc(var(--height-a) * 6); |
| 885 | + zoom: 33%; |
838 | 886 | }
|
839 | 887 | #output[data-format="text"] .placeholder.center * {
|
840 | 888 | margin: 0 auto;
|
|
0 commit comments