forked from tojocky/node-printer
-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy pathprintFile.js
30 lines (28 loc) · 925 Bytes
/
printFile.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
// use: node printFile.js [filePath printerName]
var printer = require("../lib"),
filename = process.argv[2] || __filename;
console.log('platform:', process.platform);
console.log('try to print file: ' + filename);
if( process.platform != 'win32') {
printer.printFile({filename:filename,
printer: process.env[3], // 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);
}
});
} else {
// not yet implemented, use printDirect and text
var fs = require('fs');
printer.printDirect({data:fs.readFileSync(filename),
printer: process.env[3], // 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);
}
});
}