receiptline / receiptline

Markdown for receipts. Printable digital receipts. Generate receipt printer commands and images.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[bug] A0 characters in the first line

Ynewtime opened this issue · comments

Updated 2022-11-09: With the latest version 1.13.0, you may not run into these issues any more, just check out receiptio and add an option -p generic, everything should be normal now.


Hi team, thanks for the great work in advance!

I would like to report a bug here, check below as a reproduction repository:

https://github.com/Ynewtime/receiptline-report

Basic description: I copied the code directly from https://github.com/receiptline/receiptio and tried to print out something, but there is always an A0 characters in the first line:

const receiptio = require('receiptio');

const receiptmd = `^^^RECEIPT

12/18/2021, 11:22:33 AM
Asparagus | 1| 1.00
Broccoli  | 2| 2.00
Carrot    | 3| 3.00
---
^TOTAL | ^6.00`;

receiptio.print(receiptmd, '-d 192.168.192.168 -p escpos -c 42').then(result => {
    console.log(result);
});

I switched another printer model but it appeared again.

1

So I suspect if it was related to the receiptline codebase.

Thanks again for the great work!

Thanks for your report!

escpos is designed at the command level of Epson TM-T88IV released in 2006.
It seems that your models have not reached this compatibility level.

A0 in the first line is the FS ( A command.
0 before the horizontal line is the FS C n command.

Probably image printing and upside-down printing will not work correctly either.

We will consider adding a command set using the old ESC/POS.

Thanks for feedback!

Yah my printer modals may not be compatible with this great tool but I've found some workaround to resolve the A0 in the first line and 0 before the horizontal line issue:

A0 in the first line issue: By updating this line to:

return '\x1b@\x1da\x00\x1bM' + (printer.encoding === 'tis620' ? 'a' : '0') + '\x1b \x00\x1cS\x00\x00' + (this.spacing ? '\x1b2' : '\x1b3\x00') + '\x1b{' + $(this.upsideDown) + '\x1c.';

0 before the horizontal line issue: By updating this line to:

hr: (width) => '\x1cC\x00\x1c.\x1bt\x01' + '\x95'.repeat(width),

Same testing code:

const receiptio = require('receiptio');

const receiptmd = `^^^RECEIPT

12/18/2021, 11:22:33 AM
Asparagus | 1| 1.00
Broccoli  | 2| 2.00
Carrot    | 3| 3.00
---
^TOTAL | ^6.00`;

receiptio.print(receiptmd, '-d 192.168.192.168 -p escpos -c 42').then(result => {
    console.log(result);
});

Result comparison:

image

I am still learning how to know which compatibility level my models support, hopefully can help!

Thank you very much!

The following issue and pull request may be helpful.

We will try an experimental implementation for generic printers.

Really helpful! Thanks, I've customized the commands and it works great!

Just review the latest 1.13.0 commits, and boom! It works amazingly great, now all the custom commands I made for my printers can be removed, just by adding an option in receiptio: -p generic! Also I tested the QR code support and it's also there! Really amazing work, thank you teams.