printing - Ghostscript PDF 多页多副本打印不整理
问题描述
这是我的 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;
}
在多份多页打印的情况下,我想拼贴页面。我尝试打印到许多设备,例如,也在 Windows 的 PDF 打印机中,但我总是得到未整理的打印。
这就是我要的:
但这就是我使用这个参数得到的:
switches.Add("-dNumCopies=" + nrcopies);
这是等效的 GS 命令:
gswin64.exe -empty -dPrinted -dNOSAFER -dNumCopies=2 -sDEVICE=mswinpr2 -dQueryUser=3 -f "C:\Users\myuser\Desktop\TEST.pdf"
解决方案
推荐阅读
- javascript - 使用正则表达式和节点 js 进行弹性搜索多词部分匹配
- javascript - 使用 MutationObserver 在 DOM 元素更新上显示模式
- python - 如何创建一种方法来检索 excel 文件中的电子表格列表并将工作表作为字典返回?
- python - 如何保存 TensorFlow Core 模型?
- javascript - discord.js 成员按显示名称查找返回未定义
- python - 在 macOS Big Sur 上,在 python 中加载 dylib 失败:`Symbol not found: ___addtf3`
- excel - 如何在服务器端的 Excel 中实现“组织帐户”身份验证?
- flutter - await 函数不返回值
- performance - 在 Kubernetes 容器中生成 Java 堆转储
- java - Scanner 对象不读取用户输入;java.util.NoSuchElementException:找不到行