GeezerVison is showing github.com — Nodejs document printing · Issue #13915 · nodejs/node
Nodejs document printing #13915Labels child_processIssues and PRs related to the child_process subsystem.questionIssues asking questions about Node.js.windowsIssues and PRs related to the Windows platform. DescriptionHello,
Recently I've installed node-printer module but it doesn't work and I don't know why :(
When I try to log Printer.list() command (Get available printers list) it returns an empty array despite of the fact that I have a working printer and drivers installed.
I really want to use nodejs for document printring.
I'm curious to know exactly how this module works? Does it send file to the printing queue or communicates directly to the printer?
Is there any way just to send files to the printing queue through a standard OS command? I know that it is pretty simple to do for win and linux using python. Unfortunately it is not feasible for node yet. But I don't want to use python script in conjunction with node!
Does anyone use node-printer module? Do you need any specific settings or installation for this?
I know that node has an os module but it only returns information about the system. Is it possible to create some function for node similar to python's that will start a file with associated application by os?
For e.g. this is code that works perfectly in python:
import os
os.startfile("printme.txt", "print")
Is it possible to do the same with just node child_process?
- Version: 7.0.0
- Platform: Win 7 64-bit
- Printer: Brother HL-2130 series
Activitycjihrig commented on Jun 26, 2017 You can view the code and issue tracker for that module at https://github.com/alepee/node-printer. However, it was last published 2 years ago, and according to the README, the module should not be used. TimothyGu commented on Jun 26, 2017 This issue seems to apply to the node-printer module, not Node.js itself. Please redirect your question to node-printer. Either way, it seems to me that the node-printer module depends on CUPS, which is Unix-only. changed the title [-]Node-printer issue[/-] [+]Nodejs document printing[/+] on Jun 26, 2017lumenier1 commented on Jun 26, 2017 I wanted to raise the issue of printing documents in general.
What about child_process?
Please do not say that I have to use python for this. TimothyGu commented on Jun 26, 2017 I'm not quite sure what
os.startfile("printme.txt", "print")
does in Python, but if it is equivalent to print printme.txt in cmd.exe then either
const stdout = child_process.execSync('print printme.txt');
// or
child_process.exec('print printme.txt', (err, stdout, stderr) => {
// ...
});
should suffice.
I'll close this ticket for now, but for future questions like this you should find more help at, well, nodejs/help. lumenier1 commented on Jun 26, 2017 Thank you so much, that is exactly what I want!
const stdout = child_process.execSync('print printme.txt');
is is equivalent to os.startfile("printme.txt", "print") lumenier1 commented on Jun 28, 2017 Omg, could somebody explain this, now the same code doesn't work!
const stdout = child_process.execSync('start printme.txt'); is fine, but const stdout = child_process.execSync('print printme.txt'); doesn't work anymore. Before that I thought that this was my mistake, but now I realized that this print command does not always work.
What's wrong with node??? refack commented on Jun 28, 2017 lumenier1 commented on Jun 30, 2017 Thank you for taking some time for the answer.
There is no error, but stdout log contains this string �� 㤠���� ���樠������� ���ன�⢮ PRN
Code sample:
var child_process = require('child_process');
child_process.exec('print printme.txt', (err, stdout, stderr) => {
console.log(err, stdout, stderr);
});
At some point this code sample used to work, but now it doesn't.
I mean that earlier the file was sent to printing queue when this script was launched. Now nothing appears in the printing queue by script execution. It is very strange. Why the same thing works perfectly with python but fails unpredictably with nodejs on the same system?
MetadataMetadatachild_processIssues and PRs related to the child_process subsystem.questionIssues asking questions about Node.js.windowsIssues and PRs related to the Windows platform. DevelopmentNo branches or pull requestsIssue actions
|