获取在C#中实际结束打印的时刻

时间:2019-01-13 08:20:10

标签: c# .net printing

我正在用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();

1 个答案:

答案 0 :(得分:0)