繁体   English   中英

`PrintQueue.AddJob`没有完成

[英]`PrintQueue.AddJob` does not finish

我尝试在某些PC上使用代码。

using (var lps = new LocalPrintServer())
using(var pqueue = lps.GetPrintQueue("PRINTER-NAME"))
{
    pqueue.AddJob("job-name", @"C:\example.xps", false, pticket);
}

仅在一台PC上,它不起作用。 该应用程序冻结在AddJob方法。 它在等待很长时间后甚至没有完成。 没有例外。

出现此问题的PC是Windows10并应用了CreatorsUpdate。 其他PC是Windows7,Windows8.1和Windows10应用的AnniversaryUpdate。

这个问题是CreatorsUpdate的错误吗?

补充:
具有CreatorsUpdate的PC可以通过此代码打印xps文件。

using (var lps = new LocalPrintServer())
using(var pqueue = lps.GetPrintQueue("PRINTER-NAME"))
using (var doc = new XpsDocument(@"C:\example.xps", System.IO.FileAccess.Read))
{
    var writer = PrintQueue.CreateXpsDocumentWriter(pqueue);
    var docSeq = doc.GetFixedDocumentSequence();
    writer.Write(doc, pticket);
}

我确信目标打印机驱动程序不是基于XPS的。 我遇到了同样的问题。

您可以先通过以下方式检查打印机的兼容性:

LocalPrintServer server = new LocalPrintServer(PrintSystemDesiredAccess.AdministrateServer);
PrintQueue queue = server.GetPrintQueue("MyPrinterName");            
MessageBox.Show(queue.IsXpsDevice.ToString());

如果结果是假的,那就是原因。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM