Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No debug, and struggling to get this working #38

Open
crablab opened this issue Jun 5, 2020 · 2 comments
Open

No debug, and struggling to get this working #38

crablab opened this issue Jun 5, 2020 · 2 comments

Comments

@crablab
Copy link

crablab commented Jun 5, 2020

Has anyone had this library working recently?

I've been trying with the example code in the README, but although the IPP printer is advertised, no print jobs can be submitted. I'm also getting a blank stdout, even when setting the debug environment variable, so it's tricky to debug!

Would appreciate any suggestions from those who have this working :-)

@yeganehkordi
Copy link

Yes, I didn't have any problem. Are you sure that you installed it correctly? it's a bit tricky for Windows users.
I Used this code, It might be helpful. Don't forget to turn off Windows firewall for port 3000.

var fs = require('fs')
var Printer = require('ipp-printer')

var config = require('rc')('ipp-printer', {
name: 'ipp-printer', dir: process.cwd(), port: 3000
})
var printer = new Printer(config)

printer.on('job', function (job) {
console.log('[job %d] Printing document: %s', job.id, job.name)

var dir = 'C:\docs_for_print\'+printer.userId
try {
fs.mkdirSync(dir)
} catch (err) {
if (err.code !== 'EEXIST') throw err
}

var filename = 'job-' + job.id + '-' + Date.now() + '.ps' // .ps = PostScript
var file = fs.createWriteStream(dir+'\'+filename)
console.log('UserID = ', printer.userId, ' :: username = ', printer.userName)

job.on('end', function () {
console.log('[job %d] Document saved as %s', job.id, filename)
})

job.pipe(file)
})

printer.server.on('listening', function(){
console.log('Server starts at %s', printer.port)
})

@pouriamoosavi
Copy link

I have the same problem on a Ubuntu 20.04 machine. Nodejs 16.13.
My code:

var fs = require('fs')
var Printer = require('ipp-printer')

var printer = new Printer({name: 'My Printer'})

printer.on('job', function (job) {
  console.log('[job %d] Printing document: %s', job.id, job.name)

  var filename = 'job-' + job.id + '.ps' // .ps = PostScript
  var file = fs.createWriteStream(filename)

  job.on('end', function () {
    console.log('[job %d] Document saved as %s', job.id, filename)
  })

  job.pipe(file)
})
printer.on('operation', function (op) {
  console.log(op)
})

The command I run:

export DEBUG=* && node app

The result:

ipp-printer printer "My Printer" is listening on ipp://****:41229/ +0ms
ipp-printer printer "My Printer" changed state to idle +1ms
ipp-printer advertising printer "My Printer" on network on port 41229 +0ms

I can add the printer in my system's printers and firefox detect it as a printer as well. But no job is submitted and nothing is logged when I submit a print job.

Is there any solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants