-
Notifications
You must be signed in to change notification settings - Fork 0
/
brady.js
58 lines (42 loc) · 1.33 KB
/
brady.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
#! /usr/bin/env node
var printer = require('printer');
var list = printer.getPrinters(),
formats = printer.getSupportedPrintFormats(),
commands = printer.getSupportedJobCommands();
// console.log(formats);
// console.log(commands);
var printerName = 'Brady IP300 Printer';
// console.log(filename);
// console.log(filenameX);
// console.log(template);
function XMLString(doc){
return new (XMLSerializer()).serializeToString(doc);
}
function printFile() {
return printer.printFile(
{
filename: filename,
printer: printerName, // printer name, if missing then will print to default printer
success: function (jobID) {
console.log("sent to printer with ID: " + jobID);
},
error: function (err) {
console.log(err);
}
})
}
// printFile();
function printRaw() {
return printer.printDirect(
{
data: 'Test Label' // or simple String: "some text"
,printer: printerName // printer name, if missing then will print to default printer
, type: 'TEXT' // type: RAW, TEXT, PDF, JPEG, .. depends on platform
, success:function(jobID){
console.log("sent to printer with ID: "+jobID);
}
, error:function(err){console.log(err);}
}
)
}
printRaw();