I'd like to print PDF file(s) on windows' network printer via GhostScript.
(I dont want to use Adobe Reader)
I've read gswin32c.exe which can do the job.
I experimented with many commands and coudn't find the way how to force gs to print PDF on my (windows default) network drive.
I don't need point exact network printer- default can be used. But if there is no such option I'm happy to pass printer name as well. (I've tried with param -SDevice="server_IPprinter_name" but this didnt work as well...)
Command working under Windows cmd:
gswin32c -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dNumCopies=1 -sDEVICE=ljet4 -sOutputFile="\spool\Server_NamePrinter_name" "C:est.pdf"
Method created base on above - doesnt work and thorws exception. (Error code = 1)
/// <summary>
/// Prints the PDF.
/// </summary>
/// <param name="ghostScriptPath">The ghost script path. Eg "C:Program Filesgsgs8.71ingswin32c.exe"</param>
/// <param name="numberOfCopies">The number of copies.</param>
/// <param name="printerName">Name of the printer. Eg \server_nameprinter_name</param>
/// <param name="pdfFileName">Name of the PDF file.</param>
/// <returns></returns>
public bool PrintPDF (string ghostScriptPath, int numberOfCopies, string printerName, string pdfFileName) {
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.Arguments = " -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dNumCopies=" + Convert.ToString(numberOfCopies) + " -sDEVICE=ljet4 -sOutputFile="\\spool" + printerName + "" "" + pdfFileName + """;
startInfo.FileName = ghostScriptPath;
startInfo.UseShellExecute = false;
Process process = Process.Start(startInfo);
return process.ExitCode == 0;
}
Any idea how to make it working under C#?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…