我有一個要求打印一堆現有的PDF文件的每天的網絡理光MP 4000打印機。我需要使用「HoldPrint」作業類型選項來打印這些文件。我可以直接打印,但我希望它做一個不會與其他用戶打印混淆的保留打印。我使用GhostScript的9.10 直接打印(通過函數調用從 「馬切伊」 的帖子)的一個:批量打印使用的Ghostscript理光MP 4000打印機的PDF文件的Adobe沒有
「-dPrinted -dBATCH -dNOPAUSE -dNOSAFER -qQUIET -sjobtype = holdprint -suserid = ABC -dNumCopies = 1 -sDEVICE = ljet4 -sOutputFile = \「\\ spool \ PrinterName \」\「C:\ Printing \ mypdffile.pdf \」「
看起來我覆蓋jobtype開關,但不知道如何得到它。
我嘗試不同的組合,但它根本不起作用。任何幫助是極大的讚賞。
-dPrinted -dBATCH -dNOPAUSE -dNumCopies = 1 -sDEVICE = ljet4 -sOutputFile =%打印機%PRINTERNAME 「C:\打印\ 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;
}
}
謝謝你肯。我發現部分解決方案。 「-dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dNumCopies =」 + Convert.ToString(numberOfCopies)+ 「-sDEVICE = mswinpr2 -sOutputFile =%打印機%」 + PRINTERNAME + 「\」 「+ pdfFullFileName + 」\「」;唯一的一點是我通過它的配置選項卡直接在打印機上控制作業類型屬性。現在我遇到的問題是,打印隊列中的所有作業都被命名爲Ghost腳本文檔。尋找動態發送文檔名稱。迄今沒有成功。從gs網站,它完成使用setup.ps文件,但不知道我們如何發送每個docname! –
這裏是我最初是指一篇:HTTP://stackoverflow.com/questions/2599925/how-to-print-pdf-on-default-network-printer-using-ghostscript-gswin32c-exe-she RQ = 1 –
我不太確定我是否理解你的問題,不管它是什麼,聽起來都不像Ghostscript。如果你自己控制打印機,那麼這個工作名稱肯定是由你決定的?如果您參考您正在閱讀的Ghostscript文檔(文檔以HTML文件形式提供,您不需要使用該網站),也可能有所幫助。 – KenS