lsongdev / node-escpos

🖨️ ESC/POS Printer driver for Node.js
https://npmjs.org/escpos
Other
1.38k stars 423 forks source link

Table working incorrect #333

Open ngvcanh opened 3 years ago

ngvcanh commented 3 years ago

I using:

The following code I use to print data for the table

printer
    .tableCustom([
      { text: '메뉴 x 수량', width: 0.3, align: 'LEFT' },
      { text: '금액', width: 0.4,  align: 'RIGHT' }
    ], { encoding: 'EUC-KR' });
    printer.drawLine();
    data.foods.map(food => {
      printer.tableCustom([
        { text: food.food_name + ' x ' +  food.quantity, width: 0.3, align: 'LEFT' },
        { text: food.total_price, width: 0.4, align: 'RIGHT' }
      ], { encoding: 'EUC-KR' });
    });
    printer
    .tableCustom([
      { text: '배달비', width: 0.4, align: 'LEFT' },
      { text: data.delivery_fee, width: 0.4, align: 'RIGHT' }
    ]);

And receipt when I print with 2 datas

Imgur

Imgur

It seems that calculating the text length and cell width doesn't work properly

shraey-chikker commented 2 years ago

Hey @ngvcanh , were u able to find a solution for this?

ngvcanh commented 2 years ago

Hey @ngvcanh , were u able to find a solution for this?

I haven't worked with it for a long time. However I did rewrite some of the code, check it out

https://github.com/ngvcanh/node-printer

I'm planning to rewrite it with Typescript, but time doesn't allow me to do that

Louis-jk commented 2 years ago

Hey @ngvcanh , were u able to find a solution for this?

I haven't worked with it for a long time. However I did rewrite some of the code, check it out

https://github.com/ngvcanh/node-printer

I'm planning to rewrite it with Typescript, but time doesn't allow me to do that

Hi~ @ngvcanh I need your help about table styling. please Help me. Thank you for advance.