Javascript 如何使用Node.js将docx文件打印到打印机
我试图在node.js中编写一个程序,允许用户将docx文件打印到打印机上 任何人都可以在Node.js中演示它是如何完成的?您可以使用该模块 下面是如何使用它打印文件的示例:Javascript 如何使用Node.js将docx文件打印到打印机,javascript,node.js,printing,printers,Javascript,Node.js,Printing,Printers,我试图在node.js中编写一个程序,允许用户将docx文件打印到打印机上 任何人都可以在Node.js中演示它是如何完成的?您可以使用该模块 下面是如何使用它打印文件的示例: // use: node printFile.js [filePath printerName] var printer = require("printer"), filename = process.argv[2] || __filename; console.log('platform:', proces
// use: node printFile.js [filePath printerName]
var printer = require("printer"),
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);
}
});
}
打印机不是一个模块,当我将其更改为
require('node-printer')
printDirect不是一个函数。。。。。。。。。