bebo925 / ng-thermal-print

Angular module for connecting and printing to thermal printers.
MIT License
42 stars 44 forks source link

Receipt Styling #63

Open shajeermhmmd opened 2 years ago

shajeermhmmd commented 2 years ago

The printer is connected and working with "Hello world!", Now I need to style the receipt, How we can style the receipt with Company Logo, Barcode/QR code in ng-thermal-print?

shajeermhmmd commented 2 years ago

Finally, I got the solution... I used the following print function, thanks for the wonderful plugin to connect with Printers,

print() { var esc = '\x1B'; //ESC byte in hex notation var newLine = '\x0A'; //LF byte in hex notation

var cmds = esc + "@"; //Initializes the printer (ESC @)
cmds += esc + '!' + '\x38'; //Emphasized + Double-height + Double-width mode selected (ESC ! (8 + 16 + 32)) 56 dec => 38 hex
cmds += 'BEST DEAL STORES'; //text to print
cmds += newLine + newLine;
cmds += esc + '!' + '\x00'; //Character font A selected (ESC ! 0)
cmds += 'COOKIES                   5.00'; 
cmds += newLine;
cmds += 'MILK 65 Fl oz             3.78';
cmds += newLine + newLine;
cmds += 'SUBTOTAL                  8.78';
cmds += newLine;
cmds += 'TAX 5%                    0.44';
cmds += newLine;
cmds += 'TOTAL                     9.22';
cmds += newLine;
cmds += 'CASH TEND                10.00';
cmds += newLine;
cmds += 'CASH DUE                  0.78';
cmds += newLine + newLine;
cmds += esc + '!' + '\x18'; //Emphasized + Double-height mode selected (ESC ! (16 + 8)) 24 dec => 18 hex
cmds += '# ITEMS SOLD 2';
cmds += esc + '!' + '\x00'; //Character font A selected (ESC ! 0)
cmds += newLine + newLine;
cmds += '11/03/13  19:53:17';

this.printService.init()     
    .setSize('normal')
    .writeLine(cmds)
    .feed(4)
    .cut('full')
    .flush();

}