Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I'm trying to send directly documents to my printer. I have used node-printer and have not error, but printer is not receiving anything. This is my code:
var printer = require("printer");
filename = process.argv[2] || __filename;
console.log('platform:', process.platform);
console.log('default printer name: ' + (printer.getDefaultPrinterName() || 'is not defined on your computer'));
console.log('try to print file: ' + filename);
if( process.platform != 'win32') {
printer.printFile({filename:filename,
printer: process.env[3],
success:function(jobID){
console.log("sent to printer with ID: "+jobID);
error:function(err){
console.log(err);
} else {
var fs = require('fs');
printer.printDirect({
data:fs.readFileSync(filename).toString(),
printer: process.env[3],
type: 'RAW',
success:function(jobID){
console.log("sent to printer with ID: "+jobID);
error:function(err){
console.log(err);
I test do "node print.js lorem.txt" and it looks like document is sent to print queue, but net printer is not receiving anything.
By the way, I'm working on Windows 10.
–
You are specifying the printer with printer: process.env[3]
but looks like you want to use the default printer because you are writing printer.getDefaultPrinterName()
to console, so please try removing printer: process.env[3],
and make the module to print in the default printer and see if that solves your issue.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.