在C#

时间:2018-12-08 22:05:13

标签: c# printing driver xps inf

我正在尝试在GrayScale中打印现有的XPS文件。 我试图在XPS文件中添加PrintTicket,还尝试更改打印机的PrintQueue属性,例如:

     LocalPrintServer server = new   LocalPrintServer(PrintSystemDesiredAccess.AdministrateServer);
      PrintQueue pq = server.GetPrintQueue("MyPrinterName");
      pq.DefaultPrintTicket.OutputColor = OutputColor.Grayscale;
      PrintSystemJobInfo print = pq.AddJob("myPrintJob", "MyFileToPrint.xps",false);

但是仍然以彩色打印文件...

因此,我考虑在驱动程序设置中更改打印设置,例如:

enter image description here

enter image description here

因此,是否可以通过编程方式更改此选项?

1 个答案:

答案 0 :(得分:1)

改变全局状态来解决局部问题通常是一个坏主意。随任务提交打印票应该允许您寻找所需的控制。你尝试过类似的东西吗?

LocalPrintServer server = new LocalPrintServer(PrintSystemDesiredAccess.AdministrateServer);
PrintQueue pq = server.GetPrintQueue("MyPrinterName");
var jobTicket = pq.DefaultPrintTicket;
jobTicket.OutputColor = OutputColor.Grayscale;
PrintSystemJobInfo print = pq.AddJob("myPrintJob", "MyFileToPrint.xps", false, jobTicket);