From 589ff212ae3a05a53fe36c8bc42fb8050010455b Mon Sep 17 00:00:00 2001 From: Alexandre Segura Date: Mon, 4 Mar 2024 17:42:13 +0100 Subject: [PATCH] Use new esc-pos methods to format ticket. --- src/utils/order.js | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/utils/order.js b/src/utils/order.js index 5bfe7b770..f001ad086 100644 --- a/src/utils/order.js +++ b/src/utils/order.js @@ -47,34 +47,31 @@ export function encodeForPrinter(order) { .initialize() .codepage(CODEPAGE) .align('center') - // Set double height text size - // @see https://github.com/mike42/escpos-php/blob/dcb569a123d75f9f6a4a927aae7625ca6b7fdcf3/src/Mike42/Escpos/Printer.php#L954-L960 - // @see https://github.com/NielsLeenheer/EscPosEncoder/pull/21 - .raw([ 0x1b, 0x21, 16 ]) - .line(hr) - // Double width/height + emphasize - .raw([ 0x1b, 0x21, (16 + 32 + 8) ]) + .height(2) + + encoder + .rule() + .width(2) + .bold(true) .line(`#${order.number}`) .newline() - .raw([ 0x1b, 0x21, 16 ]) + .width(1) + .bold(false) .line(i18n.t('RECEIPT_CUSTOMER_NAME', { customer: order.customer.fullName || order.customer.email })) - .line(hr) + .rule() encoder - .align('center') .line(pickupLineDate) - - encoder.raw([ 0x1b, 0x21, (16 + 32 + 8) ]) - - encoder - .align('center') + .newline() + .width(2) + .bold(true) .line(pickupLineTime) - - encoder.raw([ 0x1b, 0x21, 16 ]) + .rule() + .newline() encoder - .line(hr) - .newline() + .width(1) + .bold(false) order.items.forEach((item) => {