title: Batch printing PDF files on Ricoh MP 4000 printer using Ghostscript without Adobe
body: <p>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):</p>
  
  <p>" -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -qQUIET -sjobtype=holdprint -suserid=abc -dNumCopies=1 -sDEVICE=ljet4 -sOutputFile=\"\\spool\PrinterName\" \"C:\Printing\mypdffile.pdf\" "</p>
  
  <p>Looks like I am overwriting the jobtype switch but not sure how to get it.</p>
  
  <p>I tried different combinations but it simply does not work. Any help is greatly appreciated.</p>
  
  <p>-dPrinted -dBATCH -dNOPAUSE -dNumCopies=1 -sDEVICE=ljet4 -sOutputFile=%printer%printerName "C:\Printing\mypdffile.pdf"</p>
  
  <p>Update: Here is the version that worked for me.</p>
  
  <pre><code>        /*
           * 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 =&gt; 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);
          }
  
  
      /// &lt;summary&gt;
      /// Print PDF.
      /// &lt;/summary&gt;
      /// &lt;param name="ghostScriptPath"&gt;The ghost script path. Eg "C:\Program Files\gs\gs9.10\bin\gswin32c.exee"&lt;/param&gt;
      /// &lt;param name="numberOfCopies"&gt;The number of copies.&lt;/param&gt;
      /// &lt;param name="printerName"&gt;Exact name of the printer as seen under Devices and Printers.&lt;/param&gt;
      /// &lt;param name="pdfFileName"&gt;Name of the PDF file.&lt;/param&gt;
      /// &lt;returns&gt;&lt;/returns&gt;
  
      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;
          }
      }
  </code></pre>