Skip to content

Commit

Permalink
Use new esc-pos methods to format ticket.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsegura committed Mar 4, 2024
1 parent 89406ca commit 589ff21
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions src/utils/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {

Expand Down

0 comments on commit 589ff21

Please sign in to comment.