0

I'm working on a project wherein I'd like to interface with a local printer through node.

Everything I've read implies that this is impossible without some user interaction but I'm not sure if this takes into consideration that the printer being used is personal and could be configured/tampered with in order to provide this functionality.

The printer is a Color LaserJet Pro MFP M281fdw and if there are any third party libraries/methods of connecting to the printer through something on the backend (another part of this project is receipt printing through a thermal printer-- for which I plan on using EscPos-- is there anything similar for commercial printers)? I'd appreciate any input as to the feasibility of this once again considering I have unfettered access to the printer in question.

I've looked into several options printjs, a package called pdf-to-print, etc. and none of them provide the hands-free experience I'd hoped and I acknowledge this is a security feature but I'd imagine there's some way to make it work for internal-use purposes.

0

1 Answer 1

0

I am not sure where it was implied it was impossible, if a user interface is "needed" all it does is translate user input into variables in code and then executes presumably a network request.

I saw you tagged the question node so I looked into it and found https://www.npmjs.com/package/printer, a packae to bind to printers (for windows, if you are on a different OS do let me know, you said a personal printer so its a safe bet)

according to the examples (https://github.com/tojocky/node-printer/tree/master/examples):

var printer = require('printer');
var fs = require('fs');
var info = fs.readFileSync('yourfile.pdf').toString();

function sendPrint() {
  printer.printDirect({
    data: info,
    type: 'RAW',
    success: function (jobID) {
      console.log("printed");
    },
    error: function (err) {
      console.log('error: '+err);
      throw err;
    }
  });
}

sendPrint();

note I did not test this but it should work, other than that, in case it doesnt, I would look for different library, maybe start with python as it tends to have more libraries, and make sure you use the keywords physical printer as I feel like you missed the correct results due to maybe getting results regarding console prints

here is a medium article about printing with python

https://dev.to/pa4kev/printing-on-paper-with-python-n79

could you specify at which point do you see the printin process via these examples I provided are not hands free in case I missed it? judging by the documentation as long as your printer has ink, paper, and is ready to print such as if u pressed print from your browser UI, this will work (as its not very different from how the browser ui works, just without the ui part).

Not the answer you're looking for? Browse other questions tagged or ask your own question.