node-printer icon indicating copy to clipboard operation
node-printer copied to clipboard

How to print x copy ?

Open almottier opened this issue 8 years ago • 3 comments

How can I print x times a document ?

almottier avatar Jun 05 '17 09:06 almottier

I used this module only to print direct commands. To print x copies I suppose you can achieve this by using command attributes.

Feel free to share your solution

tojocky avatar Jun 13 '17 04:06 tojocky

You can use option argument to pass CUPSOptions Like:

            printer.printDirect({data:original
              , type: 'JPEG'
              , options: {'copies': 2}
              , success:function(jobID){
                console.log("sent to printer with ID: "+jobID);
              }
              , error:function(err){console.log(err); }
            });

irfan798 avatar Feb 17 '18 17:02 irfan798

So, I am still unable to get multiple copies out of my printer using this library.

If I understand correctly then the printDirect() method can take an options argument which should be a list of CUPS options in JSON format.

According to the CUPS documentation, the argument which triggers multiple copies to be printed is -n.

https://www.cups.org/doc/options.html

When I try it in my code, it doesn't work.... anyone got any ideas?

function print (printJobObject) {
  const printJobOptions = {
    '-n': Number(printJobObject.copies)
  }

  printer.printDirect({
    data: printJobObject.data,
    printer: printJobObject.printerName,
    type: 'RAW',
    options: printJobOptions,
    success () {
      logger.info('printed')
    },
    error (err) { logger.error(err) }
  })
}

Slos avatar Mar 10 '20 12:03 Slos