Printing Ghostscript PDF多页多份打印不';不核对

Printing Ghostscript PDF多页多份打印不';不核对,printing,ghostscript,ghostscript.net,Printing,Ghostscript,Ghostscript.net,这是我的C#和Ghostscript.NET库的静默PDF打印代码: public bool Print(string inputFile, string printerName, int nrcopies) { if (nrcopies < 1) nrcopies = 1; if (!File.Exists(inputFile) || !inputFile.ToLower().

这是我的C#和Ghostscript.NET库的静默PDF打印代码:

        public bool Print(string inputFile, string printerName, int nrcopies)
        {
            if (nrcopies < 1)
                nrcopies = 1;
            if (!File.Exists(inputFile) || !inputFile.ToLower().EndsWith(".pdf"))
                throw new ApplicationException("File not found or not valid");
            bool defaultPrinter = String.IsNullOrWhiteSpace(printerName);
            using (GhostscriptProcessor processor = new GhostscriptProcessor())
            {
                List<string> switches = new List<string>();
                switches.Add("-empty");
                switches.Add("-dPrinted");
                switches.Add("-dBATCH");
                switches.Add("-dNOPAUSE");
                switches.Add("-dNOSAFER");
                switches.Add("-dNumCopies=" + nrcopies);
                switches.Add("-sDEVICE=mswinpr2");
                if(defaultPrinter)
                    switches.Add("-dQueryUser=3");
                else
                    switches.Add("-sOutputFile=%printer%" + printerName);
                switches.Add("-f");
                switches.Add(inputFile);
                try
                {
                    processor.StartProcessing(switches.ToArray(), null);
                }
                catch (Exception) { }
            }
            return true;
        }

这是等效的GS命令:

gswin64.exe -empty -dPrinted -dNOSAFER -dNumCopies=2 -sDEVICE=mswinpr2 -dQueryUser=3 -f "C:\Users\myuser\Desktop\TEST.pdf"

Ghostscript不会为您进行排序,因此,如果您希望对页面进行排序,则只有在打印机支持的情况下才能进行排序。我强烈怀疑PDF打印机不会。对于Ghostscript.NET,我无能为力,如果您提供一个命令行(包括标准Windows打印机,如通用PostScript打印机),那么我可以查看它。我确定我的物理打印机支持排序规则,我尝试将其设置为默认选项。我将尝试使用命令行,但是您能告诉我在哪里可以找到关于-dNumCopies参数的文档吗?当我将dNumCopies设置为多于一个时,我真的很惊讶没有整理页面打印。NumCopies的效果与在页面设备字典中设置NumCopies的效果相同。Ghostscript根本不进行排序。文档在这里:当我回到办公室时,我会给你一个更新,因为现在我糟糕的解决方案是重复n次单拷贝打印。NumCopies是Ghostscript的指令(实际上是PostScript语言的一部分),它只会导致GS生成每个页面的“NumCopies”。该值不会发送到打印机。所以看起来你的打印机只有在你告诉它做额外的拷贝时才进行排序,这是有意义的,否则它怎么知道有多少页呢。所以你需要自己做这件事;将打印机默认设置为所需的副本数,并将collate设置为true,并且不要让Ghostscript为您复制副本(即不要使用NumCopies)。
gswin64.exe -empty -dPrinted -dNOSAFER -dNumCopies=2 -sDEVICE=mswinpr2 -dQueryUser=3 -f "C:\Users\myuser\Desktop\TEST.pdf"