【发布时间】:2014-01-24 17:05:58
【问题描述】:
我需要每天将一堆现有的 PDF 文件打印到网络 Ricoh MP 4000 打印机。我需要使用“HoldPrint”作业类型选项打印这些。我可以直接打印它,但我希望它做一个不会与其他用户的打印混淆的保留打印。我正在使用 GhostScript 9.10 直接打印的(通过“Maciej”帖子中的函数调用):
" -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -qQUIET -sjobtype=holdprint -suserid=abc -dNumCopies=1 -sDEVICE=ljet4 -sOutputFile=\"\\spool\PrinterName\" \"C:\Printing\mypdffile .pdf\" "
看起来我正在覆盖作业类型开关,但不知道如何获取它。
我尝试了不同的组合,但它根本不起作用。非常感谢任何帮助。
-dPrinted -dBATCH -dNOPAUSE -dNumCopies=1 -sDEVICE=ljet4 -sOutputFile=%printer%printerName "C:\Printing\mypdffile.pdf"
更新:这是适合我的版本。
/*
* 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;
}
}
【问题讨论】:
标签: printing ghostscript