watson / ipp-printer

An IPP printer written in Node.js
MIT License
548 stars 81 forks source link

Printer is not visible on windows #21

Open jaidirectdsn opened 6 years ago

jaidirectdsn commented 6 years ago

This is my code(ipp-printer.js):

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

var printer = new Printer({name:"ipp-printer", port:8080}) console.log(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) })

then i run the code > node ipp-printer.js

But i couldn't find the printer "ipp-printer" anywhere. How can i add/find the printer? Please help me. Any help will be appreciated. I am a beginner in Node. So sorry if i am asking anything wrong.

itamardavidyan commented 3 years ago

@jaidirectdsn You solved this?

kartikbathla commented 3 years ago

How did you guys actually solve this?

itamardavidyan commented 3 years ago

I created virtual printer:

this.printer = new Printer({ name: 'PrinterName', port: 3007 })

And then I used powershell script to install the printer:

# Step 1 - Enable InternetPrinting feature
$Feature = Get-WindowsOptionalFeature -Online -FeatureName "Printing-Foundation-InternetPrinting-Client"
if ($Feature.State -ne "Enabled") {
        Enable-WindowsOptionalFeature -Online -FeatureName "Printing-Foundation-Features" -NoRestart
        Enable-WindowsOptionalFeature -Online -FeatureName "Printing-Foundation-InternetPrinting-Client" -NoRestart
}

# Step 2 - Install printer
$Result = Test-NetConnection 127.0.0.1 -Port 2404
If ($Result.TcpTestSucceeded) {
     Add-Printer -Name "PixLetter" -DriverName $PrinterDriverName -PortName "http://$($env:COMPUTERNAME):2404"
} Else {
      throw "Printer port doesn't exposed"
}
samantrader commented 1 year ago

I created virtual printer:

this.printer = new Printer({ name: 'PrinterName', port: 3007 })

And then I used powershell script to install the printer:

# Step 1 - Enable InternetPrinting feature
$Feature = Get-WindowsOptionalFeature -Online -FeatureName "Printing-Foundation-InternetPrinting-Client"
if ($Feature.State -ne "Enabled") {
        Enable-WindowsOptionalFeature -Online -FeatureName "Printing-Foundation-Features" -NoRestart
        Enable-WindowsOptionalFeature -Online -FeatureName "Printing-Foundation-InternetPrinting-Client" -NoRestart
}

# Step 2 - Install printer
$Result = Test-NetConnection 127.0.0.1 -Port 2404
If ($Result.TcpTestSucceeded) {
     Add-Printer -Name "PixLetter" -DriverName $PrinterDriverName -PortName "http://$($env:COMPUTERNAME):2404"
} Else {
      throw "Printer port doesn't exposed"
}

Hi @itamardavidyan can you explain what is relation of powershell script with use of ipp-printer
and send a full instruction for create a virtual printer with ipp-printer

itamardavidyan commented 1 year ago

@samantrader

The Powershell script seperated for 2 steps:

  1. Enable InternetPrinting feature - I don't remember why I should enable those windows features but without enable them I can't send files to the virtual printer.
  2. Install printer - The next command: Add-Printer -Name "PixLetter" -DriverName $PrinterDriverName -PortName "http://$($env:COMPUTERNAME):2404" Is a command line for adding the printer automatically to the printers list of the windows user - it's useful if you don't want that the user will add it manually

About creating virtual printer using ipp-printer you can use the code from the README.md file

samantrader commented 1 year ago

Hi If this powershell configuration is necessary for use ipp-printer ?

itamardavidyan commented 1 year ago

It's not necessary because you can do each of the steps manually

samantrader commented 1 year ago

I used exactly this code but printer donot show in list of windows printer why ?

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

var printer = new Printer('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) })`

samantrader commented 1 year ago

Hi When I run this command
$Result = Test-NetConnection 127.0.0.1 -Port 2404 powershell return error : WARNING: TCP connect to 127.0.0.1:2404 failed

how can I fix this error ?

itamardavidyan commented 1 year ago

This command: var printer = new Printer('My Printer') deson't define the port of the virtual printer Try to debug and see which port number the constructor define to the virtual printer