forked from Klemen1337/node-thermal-printer
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathexample.js
More file actions
118 lines (111 loc) · 3.24 KB
/
example.js
File metadata and controls
118 lines (111 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
var printer = require("./node-thermal-printer");
var currency = v => {
const options = { style: "currency", currency: 'BRL'};
return (new Intl.NumberFormat("pt-BR", options).format(v));
}
printer.init({
type: 'epson',
interface: '/dev/usb/lp0',
characterSet: 'LATINA',
removeSpecialCharacters: false,
replaceSpecialCharacters: true,
});
printer.alignCenter();
printer.simpleCut();
printer.execute(function(err){
if (err) {
console.error("Print failed", err);
} else {
console.log("Print done");
}
});
// var printer = require("./node-thermal-printer");
//
// printer.init({
// type: 'star', // 'star' or 'epson'
// interface: '/dev/usb/lp0',
// width: 48, // Number of characters in one line (default 48)
// characterSet: 'SLOVENIA', // Character set default SLOVENIA
// removeSpecialCharacters: false, // Removes special characters - default: false
// replaceSpecialCharacters: true, // Replaces special characters listed in config files - default: true
// //lineChar: "=", // Use custom character for drawing lines
// // ip: "localhost",
// // port: 9000
// });
//
// printer.isPrinterConnected(function(response){
// console.log("Printer connected:", response);
// });
//
//
// printer.alignCenter();
// printer.printImage('./assets/olaii-logo-black-small.png', function(done){
// printer.alignLeft();
// printer.newLine();
// printer.println("Hello World!");
// printer.drawLine();
//
// printer.upsideDown(true);
// printer.println("Hello World upside down!");
// printer.upsideDown(false);
// printer.drawLine();
//
// printer.invert(true);
// printer.println("Hello World inverted!");
// printer.invert(false);
// printer.drawLine();
//
// printer.println("Special characters: ČčŠšŽžĐđĆćßẞöÖÄäüÜé");
// printer.drawLine();
//
// printer.setTypeFontB();
// printer.println("Type font B");
// printer.setTypeFontA();
// printer.println("Type font A");
// printer.drawLine();
//
// printer.alignLeft();
// printer.println("This text is on the left");
// printer.alignCenter();
// printer.println("This text is in the middle");
// printer.alignRight();
// printer.println("This text is on the right");
// printer.alignLeft();
// printer.drawLine();
//
// printer.setTextDoubleHeight();
// printer.println("This is double height");
// printer.setTextDoubleWidth();
// printer.println("This is double width");
// printer.setTextQuadArea();
// printer.println("This is quad");
// printer.setTextNormal();
// printer.println("This is normal");
// printer.drawLine();
//
// printer.printBarcode("4126570807191");
// printer.code128("4126570807191", {
// height: 50,
// text: 1
// });
//
// printer.pdf417("4126565129008670807191");
// printer.printQR("https://olaii.com");
//
// printer.newLine();
//
// printer.leftRight("Left", "Right");
//
// printer.table(["One", "Two", "Three", "Four"]);
//
// printer.tableCustom([
// { text:"Left", align:"LEFT", width:0.5 },
// { text:"Center", align:"CENTER", width:0.25, bold:true },
// { text:"Right", align:"RIGHT", width:0.25 }
// ]);
//
//
// printer.cut();
// printer.openCashDrawer();
// printer.execute();
// });