I have a requirement to Print a bunch of existing PDF files every day to a network Ricoh MP 4000 Printer. I need to print these using "HoldPrint" job type option. I am able to print it directly but I want it to do a hold print which does not mix up with other user's printing. I am using GhostScript 9.10 The one that directly prints (through function call from "Maciej"'s post):
" -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -qQUIET -sjobtype=holdprint -suserid=abc -dNumCopies=1 -sDEVICE=ljet4 -sOutputFile=\"\\spool\PrinterName\" \"C:\Printing\mypdffile.pdf\" "
Looks like I am overwriting the jobtype switch but not sure how to get it.
I tried different combinations but it simply does not work. Any help is greatly appreciated.
-dPrinted -dBATCH -dNOPAUSE -dNumCopies=1 -sDEVICE=ljet4 -sOutputFile=%printer%printerName "C:\Printing\mypdffile.pdf"
Update: Here is the version that worked for me.
/*
* Printer used: Ricoh Aficio MP 4000
* Purpose: To print PDF files as a scheduled job to a network printer.
* The files will be queued under a specific user id.
* The user prints the files under his account.
* Pre-requisite: Install the network printer on the job server
* Manually configure Printer Job settings with user id
* and Job type set to "Hold Print"
*/
string _sourceFolder = “PDFFilesFolderPath”;
DirectoryInfo di = new DirectoryInfo(_sourceFolder);
var files = di.GetFiles().OrderBy(f => f.Name);
string _printer = "BMIS"; // Printer name as seen in the Devices and Printers section
foreach (var f in files)
{
PrintPDF(@"C:\Program Files\gs\gs9.10\bin\gswin32c.exe", 1, _printer, f.FullName);
}
/// <summary>
/// Print PDF.
/// </summary>
/// <param name="ghostScriptPath">The ghost script path. Eg "C:\Program Files\gs\gs9.10\bin\gswin32c.exee"</param>
/// <param name="numberOfCopies">The number of copies.</param>
/// <param name="printerName">Exact name of the printer as seen under Devices and Printers.</param>
/// <param name="pdfFileName">Name of the PDF file.</param>
/// <returns></returns>
public bool PrintPDF(string ghostScriptPath, int numberOfCopies, string printerName, string pdfFullFileName )
{
try
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.Arguments = " -dPrinted -dNoCancel=true -dBATCH -dNOPAUSE -dNOSAFER -q -dNumCopies=" + Convert.ToString(numberOfCopies) + " -sDEVICE=mswinpr2 -sOutputFile=%printer%" + printerName + " \"" + pdfFullFileName + "\"";
startInfo.FileName = ghostScriptPath;
startInfo.UseShellExecute = false;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
Process process = Process.Start(startInfo);
process.WaitForExit(30000);
if (process.HasExited == false) process.Kill();
return process.ExitCode == 0;
}
catch (Exception ex)
{
System.Diagnostics.EventLog.WriteEntry("Application", ex.Message, EventLogEntryType.Error);
throw;
}
}