NielsLeenheer / ReceiptPrinterEncoder

Create a set of commands that can be send to any receipt printer that supports ESC/POS, StarLine or StarPRNT
MIT License
185 stars 18 forks source link

Table with border and table auto layout #21

Open nauman-matloob opened 1 year ago

nauman-matloob commented 1 year ago

Hello, i have 2 questions.

  1. i'd like to know if there is a possiblity to add border to the table.
  2. i'd like to know how can i have the auto width between 2 columns. here is an exemple of what i am currently doing (table):
    .table(
        [
          { width: 26, align: 'left' },
          { width: 10, align: 'right', marginRight: 2, }
        ],
        order.products.reduce((a, b) => {
          a.push([
            (encoder) => encoder.bold()
              .width(2)
              .height(2)
              .align('left')
              .text(b.name),
            (encoder) => encoder.bold()
              .align('right')
              .text(b.qty.toString())
              .width(1)
              .height(1)]);
          return a;
        }, [])
      )

    but my problems is that the 1st column doesn't have an auto width and the right column does not stick on the position. also my 1st column doesn't have always the same text length. is there a problem with my code ?

NielsLeenheer commented 2 months ago

Table borders are currently not supported. That may be added in the future. The latest release does have many inprovements in table rendering and should fix most issues with columns not being the right size.