C#批量应用程序(PrintServer&PrintQueue问题)

我有一个问题,我需要帮助。 对于我目前的项目,我需要制作批量绘图应用程序。 这个应用程序将有大约2000个AutoCAD图纸需要打印。

应用程序需要5台打印机,每种格式1个,从A4到A0。 到目前为止还没有问题。

现在我们都明白,我们不能在没有某种麻烦的情况下同时排列2000张图纸。 我在网上做了我的研究,并找到了查看当前打印机队列的方法。 使用PrintServer和PrintQueue。

这是问题出现的地方。 首先,我无法找到我需要的网络打印机。 打印机位于此网络地址:192.168.0.14( vps01w2k8)。

遵循MSDN指南:

    PrintServer m_PrintServer = new PrintServer(@"vps01w2k8");
    PrintQueueCollection m_PrintQueueCollection = m_PrintServer.GetPrintQueues();

    foreach (PrintQueue queue in m_PrintQueueCollection)
    {
         cbPrinters.Items.Add(queue.Name.ToString());
    }

这不会给我任何打印机。 尝试LocalPrintServer(或只是没有任何参数传递给它的PrintServer)。 给我我的本地打印机(显然),而不是我的网络打印机。

我的下一步是找到一种方法来查找我安装的所有打印机,它们让我using System.Drawing.Printing; 而不是using System.Printing;

    foreach (String printer in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
    {
         cbPrinters.Items.Add(printer.ToString());
    }

这个简单的代码给了我所有的打印机,包括联网的打印机。 但是,现在我陷入了.NET 2.0和3.0之间(以及之后)。 类PrinterSettings和PrintServer / PrintQueue没有连接。

最后,我尝试使用WMI方法访问打印机队列。 查询给我结果的Win32_PrintJob。 不幸的是,这些伴随着10秒锁定来检索这些结果。

我没有想法。 我正在寻找打印服务器的修复程序来正确返回我的联网打印机或任何建议,以使用PrinterSettings类进行批量打印的类似技术。

提前致谢,

约迪


找到了。 当调用GetPrintQueues时,你必须传入一个EnumeratedPrintQueueTypes数组。 它现在返回本地和网络打印机(所有安装的打印机)。

PrintServer m_PrintServer = new PrintServer();
PrintQueueCollection m_PrintQueueCollection = m_PrintServer.GetPrintQueues(new[] { EnumeratedPrintQueueTypes.Local, EnumeratedPrintQueueTypes.Connections });
链接地址: http://www.djcxy.com/p/87933.html

上一篇: C# Batch plot application (PrintServer & PrintQueue issues)

下一篇: Sum array of arrays in Cython