Skip to content

Commit

Permalink
Fixed image paper feed
Browse files Browse the repository at this point in the history
  • Loading branch information
ma-zal committed Mar 31, 2023
1 parent 5837424 commit df38a06
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "escpos-buffer",
"version": "3.1.0",
"version": "3.1.1",
"description": "Library to generate buffer for thermal printers.",
"author": "GrandChef Team <[email protected]>",
"license": "MIT",
Expand Down
7 changes: 6 additions & 1 deletion src/profile/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,20 @@ export abstract class Profile {
async draw(image: Image): Promise<void> {
const low = String.fromCharCode(image.width & 0xff);
const high = String.fromCharCode((image.width >> 8) & 0xff);
// Set correct line spacing
await this.connection.write(Buffer.from('\x1B3\x10', 'ascii'));
// Print image slice by slice
for (let y = 0; y < image.lines; y++) {
// Bit-image slice
const data = image.lineData(y);
await this.connection.write(
Buffer.from(this.bitmapCmd + low + high, 'ascii'),
);
await this.connection.write(data);
await this.connection.write(Buffer.from('\x1BJ\x00', 'ascii'));
// Paper feed
await this.connection.write(Buffer.from('\x0A', 'ascii'));
}
// Reset the line spacing to default
return this.connection.write(Buffer.from('\x1B2', 'ascii'));
}

Expand Down

0 comments on commit df38a06

Please sign in to comment.