【问题标题】:Batch printing PDF files on Ricoh MP 4000 printer using Ghostscript without Adobe在没有 Adob​​e 的情况下使用 Ghostscript 在 Ricoh MP 4000 打印机上批量打印 PDF 文件
【发布时间】: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


    【解决方案1】:

    Ghostscript 没有 'jobtype' 开关,也没有 suserid 开关,所以它们没有效果也就不足为奇了。可能您引用的帖子有更多信息,但我找不到任何此类帖子,也许您可​​以指向它(URL)

    [稍后]

    Setup.ps 必须是 PostScript 文件(因为这是 Ghostscript 理解的,它是 PostScript 解释器)。从要设置 DocumentName 的文档中,它是 User Settings 字典的成员,所以:

    mark
        /UserSettings <<
            /DocumentName (My name goes in here)
        >>
        (mswinpr2) finddevice
        putdeviceprops
    setdevice
    

    空白只是为了清楚起见。这几乎是从示例中逐字提取的。

    因此,您需要修改为每个作业发送的“setup.ps”。您可以为每一个编写自定义 setup.ps,或者使用 GS 的“PostScript 输入”功能并使用 -c 和 -f 开关在命令行上提供 setup.ps 的全部内容。 setup.ps 所做的只是在运行您自己的 PostScript 程序之前在其中运行 PostScript(假设您在命令行中将 setup.ps 放在 PostScript 程序之前)。

    这其实很恶心,不是设备正常配置的方式,而是mswinpr2设备最初是由Ghostscript团队之外的人编写的,估计是批发的。

    【讨论】:

    • 谢谢肯。我部分找到了解决方案。 " -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dNumCopies=" + Convert.ToString(numberOfCopies) + " -sDEVICE=mswinpr2 -sOutputFile=%printer%" + 打印机名 + "\"" + pdfFullFileName + "\"";唯一的事情是我通过其配置选项卡直接在打印机上控制作业类型属性。现在我遇到的问题是打印队列中的所有作业都被命名为 Ghost 脚本文档。搜索以动态发送文档名称。到目前为止没有成功。来自 gs 站点,它使用 setup.ps 文件完成,但不确定我们如何发送每个文档名!
    • 这是我最初参考的帖子:stackoverflow.com/questions/2599925/…
    • 我不确定我是否理解您的问题,无论它是什么,听起来都与 Ghostscript 无关。如果您自己控制打印机,那么作业名称肯定取决于您吗?如果您参考您正在阅读的 Ghostscript 文档也可能会有所帮助(文档以 HTML 文件的形式提供,您不需要使用该网站)
    • 抱歉不清楚。在打印机设置中设置作业文档名称对所有正在打印的 PDF 文件使用相同的名称,但我想显示队列中每个文档的唯一名称。我有屏幕截图,但不知道如何上传。这是提供 setup.ps 文件的更多详细信息的链接,以通过脚本提供文档名称。 ghostscript.com/doc/9.10/Devices.htm#Win 10.2 和 10.3 节
    • 感谢 Ken 让这一点变得清晰和有用。我刚刚了解到,根据我们的代理政策,只允许使用 Adob​​e!以为我们团队内部的每个人都对策略使用有相同的了解,但肯定不是。看来我别无选择,只能忍受 Adob​​e 的随机失败!感谢您的宝贵时间。
    猜你喜欢
    • 2013-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-06
    相关资源
    最近更新 更多