Reputation: 390
I want to create a electron app that support raw printing.
Any suggestion about a library or path that I can take will be appreciated.I did a little bit of research but nothing seems to be up to date. I want to get all the printers availables and get the default printer and print with it.
I you have a small example that you can show me, It will be awesome!
Upvotes: 5
Views: 2197
Reputation: 1283
After trying several methods and packages, I was able to achieve success by:
Note, I have only used and tested on Windows.
yarn add node-cmd
Example
const fs = window.require('fs')
const path = window.require('path')
const cmd = window.require('node-cmd')
//Save the raw output to the filesystem
const filePath = path.join(__dirname, 'rawprint.prn') //or wherever you want to save it
//Create a command to copy the file to the shared printer path (e.g. \\localhost\DPD ). Make sure that var is sanitised first!
const command = `COPY /B "${filePath}" "${pathToSharedPrinter}"`
cmd.get( command, (err, data, stderr) => {
if ( !err ) {
console.log('Success!')
} else {
console.log( err.message )
}
})
Upvotes: 1