GhostScript print to network printer in silent mode
I'm trying to print PDF from command line to network printer in silenta mode.
Unfortunately, Ghost Script opens Windows printer dialog.
I use Windows 2008 R2 Server
.
My command is:
gswin64c.exe -dBATCH -dNOPAUSE -dNumCopies=1 -sDEVICE=mswinpr2 -sOutputFile="%printer%MEasyCoder PC4 (203 dpi) on aino1" "pdf.pdf"
Printer name is: MEasyCoder PC4 (203 dpi) on aino1
and it is network printer attached to AINO1
computer.
Printer dialog looks like:
In printer panel it looks like:
What is the right command line to avoid this dialog and print silently?
Solution 1:
According to the Details of Ghostscript Output Devices, MS Windows printers:
If a Windows printer name is specified in -sOutputFile using the format
"%printer%printer_name"
, for instance:gs ... -sOutputFile="%printer%Apple LaserWriter II NT"
then Ghostscript attempts to open the Windows printer without prompting (except, of course, if the printer is connected to FILE:). Ghostscript attempts to set the Windows printer page size and orientation to match that expected by Ghostscript, but doesn't always succeed. It uses this algorithm: (not quoted here)
A sample command would be (source):
gswin64c.exe -sDEVICE=mswinpr2 -dBATCH -dNOPAUSE -sOutputFile="%printer%\\printServer\printerNameWith Spaces" testprinter.ps
Solution 2:
I use gsprint, which uses GhostScript. You will need to download the old version 5 built by GhostGum for print capabilities. If you use the default installation settings, gsprint
will be located here: C:\Program Files\Ghostgum\gsview
For your example:
gsprint -printer "\\ain01\MEasyCoder PC4 (203 dpi)" -dPDFFitPage "pdf.pdf"
Solution 3:
The correct way to print to a network printer in silent mode using GhostScript (gswin32c.exe) is to use \\spool\ and then the full UNC path on sOutput. All parameters are case senitive. Also, be sure to include double quotes.
gswin32c.exe -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dNumCopies=1 -sDEVICE=mswinpr2 -sOutputFile="\\spool\\\SRV-SBS01\iR-ADVC5030_PS_BW" "C:\Windows\Temp\~Packlist.pdf"