1

我正在尝试编写一个定期打印的应用程序。我已经开发了该应用程序,并使用我的HP Photosmart B110a打印机对其进行了测试,一切正常,但在下一台打印机上,即Lexmark MS621 上,我没有从 PrintQueue 得到任何回报。这是为什么?我错过了什么吗?

归结起来,这是必须工作的代码。

//PDFtoPrinter documentation: https://github.com/svishnevsky/PDFtoPrinter
static void Print()
{
    using (LocalPrintServer printServer = new LocalPrintServer(PrintSystemDesiredAccess.AdministrateServer))
    {
        using (PrintQueue queue = new PrintQueue(printServer, printServer.DefaultPrintQueue.Name, PrintSystemDesiredAccess.AdministratePrinter))
        {
            //Start printing
            new PDFtoPrinterPrinter().Print(new PrintingOptions(printServer.DefaultPrintQueue.Name, @"C:\Pdf\blank.pdf")).GetAwaiter().GetResult();
            queue.Refresh(); //Just to make sure I refresh the queue

            if (queue.NumberOfJobs > 1) //On my HP printer this if statement returns true after I started printing, but on the Lexmark it says there is no printjob even tho it started to print!
                Console.WriteLine("There is a job!");

            foreach (PrintSystemJobInfo info in queue.GetPrintJobInfoCollection())  //I've tried to print out all JobInfo on the printer, on the HP I get one, but on Lexmark I get 0
                Console.WriteLine(info.Name);

            PrintSystemJobInfo jobInfo = queue.GetPrintJobInfoCollection().FirstOrDefault(x => x.Name.Equals("blank.pdf")); //Get the jobInfo of the current file that I'm trying to print. Again, on HP I get the jobInfo but on the Lexmark I get nothing.

            if (queue.IsOutOfPaper)  //When I start to print without the printer having any paper this line on the HP returns true, but on the Lexmark it's alwaysfalse.
                Console.WriteLine("There is no paper!");

            if(jobInfo.IsPaperOut)  //Same problem...
                Console.WriteLine("There is no paper!");
        }
    }
}

一项附加信息。
HP 是网络打印机,Lexmark 是通过 USB 连接的,我用两者打印了一张测试页。
当然驱动程序不同,但驱动程序类型也不同!
利盟是type 3惠普的type 4,也许这与它的工作方式有关?

任何帮助将不胜感激!

4

0 回答 0