forked from Klemen1337/node-thermal-printer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.js
89 lines (72 loc) · 2.47 KB
/
example.js
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
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();
});