grandchef / escpos-buffer

Library to generate buffer for thermal printers.
MIT License
51 stars 17 forks source link

No new line by `writeln()` after bitmap image #46

Open ma-zal opened 1 year ago

ma-zal commented 1 year ago

Issue

After the bitmap image drawing the next writeln() command does not add a new line after the text. But the second text is incorrectly placed directly after the first one.

Example of code with issue:

writeln('line1.');
writeln('line2.');
draw(image);
writeln('line3.');
writeln('line4.');

Example causes the output with issue:

line1.
line2.
[Image]
line3.line4.

Root cause

I have found the incorrect ESC command in draw() function after each bitmap line.

File: src/profile/index.ts

Current (incorrect implementation):

yield this.connection.write(Buffer.from('\x1BJ\x00', 'ascii'));

Should be 0x0A only:

yield this.connection.write(Buffer.from('\x0A', 'ascii'));

ESC commands documentation

Testing:

I have tested my offered change. It corrects the issue on my side.