我正在用wpf开发一个应用程序,该应用程序可以循环打印照片,因此我想获得实际完成工作的实际时间,可以继续进行其他工作。
我正在使用PrintDocument类进行打印,我尝试了EndPrint事件,但是在将文件发送到打印机时(而不是在打印机完成其工作时)被命中。同样在系统队列中,文档在打印结束前消失。是否可以获得一些打印机状态信息?
PrintDocument pd = new PrintDocument();
PrinterSettings.PaperSizeCollection ps = pd.PrinterSettings.PaperSizes;
PaperSize size = new PaperSize();
foreach (PaperSize Psz in ps)
{
if (Psz.PaperName == ev.PaperSize)
{
size = Psz;
break;
}
}
pd.PrinterSettings.PrinterName = ev.printerName;
pd.DefaultPageSettings.PaperSize = size;
pd.DocumentName = "aaaaa";
pd.PrintPage += PrintPage2;
pd.EndPrint += new PrintEventHandler(this.PrintEnd2);
pd.Print();
var myPrintServer = new LocalPrintServer();
var pq = myPrintServer.GetPrintQueue(ev.printerName);
var jobs = pq.GetPrintJobInfoCollection();
foreach (var job in jobs)
{
var done = false;
while (!done)
{
pq.Refresh();
job.Refresh();
done = job.IsCompleted || job.IsDeleted || job.IsPrinted;
}
}
ai++;
PopAction();
答案 0 :(得分:0)
可以通过 PrintSystemJobInfo.IsCompleted 进行查找。 https://docs.microsoft.com/en-us/dotnet/api/system.printing.printsystemjobinfo.iscompleted?view=netframework-4.7.2