watson / ipp-printer

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

Is there any simple example or instruction how to use ipp-printer on windows #35

Open tigran1984 opened 4 years ago

SRodinou commented 4 years ago

What's your issue here ? I've managed to make it work so I may help

itamardavidyan commented 3 years ago

@SRodinou How you make it work on windows? can you share your code?

figox commented 3 years ago

Someone have make it work on Windows? The printer is showing, the job it's being created but the event on nodejs is not firing therefore no .ps file is created.

itamardavidyan commented 3 years ago

I wrote Powershell script for printer installation:

$PrinterName = "FillYoutPrinterName"

Write-Output "Step 1"
Try {
    # 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 | Out-Null
        Enable-WindowsOptionalFeature -Online -FeatureName "Printing-Foundation-InternetPrinting-Client" -NoRestart | Out-Null
        Write-Output "Printing-Foundation-InternetPrinting-Client feature enabled."
    } else {
        Write-Output "Printing-Foundation-InternetPrinting-Client feature already enabled."
    }
} Catch {
    Write-Output "<!--- An error occurred @ Step 1 ---!>"
    Write-Output $_.ScriptStackTrace
}

Write-Output ""
Write-Output "Step 2"
Try {
    # Step 2 - Check if printer exists
    $Printer = Get-Printer -Name $PrinterName -erroraction 'silentlycontinue'
    If ($Printer) {
        Write-Output "Printer already installed."
    } Else {
        Write-Output "Install printer..."

        # Step 2.1 - Find printer driver name
        $PrinterDriver = Get-PrinterDriver -Name "HP *" # You can change this to any other printer driver
        if ((-Not $PrinterDriver) -or ($PrinterDriver.length -eq 0)) {
            Write-Output "Can't find printer driver."
            exit 1
        }
        $PrinterDriverName = $PrinterDriver[0].Name;
        Write-Output "Driver name = $PrinterDriverName"

        # Step 2.2 - Install printer
        Write-Output "Install printer..."
        Add-Printer -Name $PrinterName -DriverName $PrinterDriverName -PortName "http://$($env:COMPUTERNAME):3007/printers/$PrinterName"

        Write-Output "Printer ($PrinterName) installed successfully."
    }
} Catch {
    Write-Output "<!--- An error occurred @ Step 2 ---!>"
    Write-Output $_.ScriptStackTrace
}

!! Don't forget to install GhostScript

Hope it's help for you :) @figox @tech-srinath