【问题标题】:Change Document Name while printing using Ghost Script使用 Ghost 脚本打印时更改文档名称
【发布时间】:2019-03-08 11:11:17
【问题描述】:

我需要将 PDF 文件打印到一些基于硬件的打印机和一些虚拟 PDF 打印机。我正在使用 Ghostscript 来完成这项任务,编程语言是 C#。

硬件打印机在每个文档之后打印一个 PrintJob 页面,其中包含一些信息,例如日期/时间和文档名称。

虚拟打印机打印文档,但名称不同。 (Ghostscript 文档)

我在使用 Ghost 脚本时无法更改/或设置文档名称,感谢任何帮助。

using (GhostscriptProcessor processor = new GhostscriptProcessor())
            {
                List<string> switches = new List<string>
            {
                //"-empty",
                "-dPrinted",
                "-dBATCH",
                "-dNOPAUSE",
                "-dNoCancel",
                "-dNOSAFER",
                "-dNumCopies=1",
                "-sDEVICE=mswinpr2",
                "-sDocumentName=" +  String.Format("\"{0}\"",Path.GetFileName(fileName)),
                "-sOutputFile=%printer%" + printerName ,
                "-f",
                fileName
            };
                processor.StartProcessing(switches.ToArray(), null);
            }

开关“sDocumentName”不起作用,我仍然看到使用默认名称打印文档 - “Ghostscript Document”

【问题讨论】:

    标签: pdf printing ghostscript silent ghostscript.net


    【解决方案1】:

    确切地说,“文档名称”是什么意思?你希望在哪里看到这个?

    没有DocumentName 开关。有一个 DocumentName 参数。如果您阅读第 10.2 节支持的选项下的文档here,它清楚地说明了

    存在一些无法通过命令行设置的额外选项,

    其中包括 DocumentName,因此尝试从命令行设置它显然不会取得任何成果。文档继续描述如何设置这些参数,因此如果您尝试更改的是呈现给 Windows 假脱机程序的名称,那么您需要阅读该部分。

    【讨论】:

    • 正如我所提到的,物理打印机打印一个打印作业页面,其中打印了文档名称。我希望在该页面上打印文档的名称。我提到的开关是“sDocumentName”,它不起作用
    • ghostscript 中的切换以 -s 或 -d 开头,这就是为什么我从 DocumentName 中删除了“s”,这是多余的。让我们更清楚一点;有 no 开关 -sDocumentName。 有 一个 DocumetnName 参数(注意缺少 -s),正如文档所述,不能从命令行将其设置为开关。由于我不知道 Windows 在哪里找到“文档名称”(这是您在提到打印页面时在问题中所称的),所以我不知道这是否会满足您的要求,但值得一试。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-12
    • 1970-01-01
    相关资源
    最近更新 更多