C#批量打印应用程序(打印服务器和放大器;打印队列的问题) [英] C# Batch plot application (PrintServer & PrintQueue issues)

查看:506
本文介绍了C#批量打印应用程序(打印服务器和放大器;打印队列的问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我需要帮助的问题。对于我目前的项目,我需要做一个批处理打印应用程序。此应用程序将有大约〜2000年的AutoCAD图纸,这将需要打印。

I have a problem that I need help with. For my current project I need to make a Batch Plot application. This application will have around ~2000 AutoCAD drawings that it will need to print.

应用程序需要5台打印机,1每种格式,去从A4至A0。没有问题,又那么远。

The application needs 5 printers, 1 for each format, going from A4 to A0. No problems yet so far.

现在大家都明白,我们不能同时排队图纸2000没有某种麻烦。我已经在网上做了我的研究,发现方法来看待当前的打印机队列。使用打印服务器并打印队列。

Now we all understand that we can not queue 2000 drawings simultaneously without some kind of trouble. I've did my research online and found methods to look at the current printer Queue. Using PrintServer and PrintQueue.

下面是问题开始的地方。首先,我无法找到我需要的网络打印机。该打印机位于该网络地址:192.168.0.14(\vps01w2k8)

Here is where the problems begin. Firstly I am not able to find the network printers that I need. The printers are located on this network address: 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(或只是打印服务器没有传递给它任何参数)。给我我的本地打印机(明显),而不是我的网络打印机。

This does not give me any printers. Trying LocalPrintServer (or just PrintServer without any parameters passed into it). Gives me my local printers (obviously) and not my network printers.

我的下一步是要找到找到我所有已安装的打印机这让我进入<$ C的方法$ C>使用System.Drawing.Printing;采用System.Printing 而不是;

My next step was to find a method to find all my installed printers which got me into using System.Drawing.Printing; instead of using System.Printing;.

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

这简单的代码给了我所有我有打印机,包括网络化的。
然而,现在我陷.NET 2.0和3.0(及以后)之间。类PrinterSettings和打印服务器/打印队列没有连接。

This simple code gives me all the printers I have, including the networked ones. However, now I am stuck between .NET 2.0 and 3.0 (and onward). The classes PrinterSettings and PrintServer/PrintQueue have no connection.

最后我尝试使用的 WMI方法。查询这给了我结果中PrintJob。不幸的是,这些走过来,10第二个锁定起坐来获取这些结果。

Lastly I tried to get access to the printer queues using the WMI approach. Querying the Win32_PrintJob which gave me results. Unfortunately these came along with 10 second lock-ups to retrieve these results.

我的想法。我不是找一个固定的打印服务器能够正常返回我的网络打印机或任何建议,做批量与PrinterSettings类绘制类似的技术。

I'm out of ideas. I'm either looking for a fix for the PrintServer to properly return my networked printers or any suggestions to do similar techniques for batch plotting with the PrinterSettings class.

在此先感谢

的Jordy

推荐答案

发现了它。当调用GetPrintQueues你有EnumeratedPrintQueueTypes的数组来传递。它现在返回我的两个本地和网络打印机(已安装的所有打印机)

Found it. When calling GetPrintQueues you have to pass in an array of EnumeratedPrintQueueTypes. It now returns both my local and network printers (all installed printers).

PrintServer m_PrintServer = new PrintServer();
PrintQueueCollection m_PrintQueueCollection = m_PrintServer.GetPrintQueues(new[] { EnumeratedPrintQueueTypes.Local, EnumeratedPrintQueueTypes.Connections });

这篇关于C#批量打印应用程序(打印服务器和放大器;打印队列的问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆