我的目标是在本地打印机上打印任何MemoryStream:
public void PrintStream(MemoryStream ms) {
byte[] bytes = new byte[ms.Length];
ms.Read(bytes, 0, (int)ms.Length);
LocalPrintServer ps = new LocalPrintServer();
PrintQueue printQueue = new PrintQueue(ps, "ZDesigner GC420t (EPL)");
using (var job = printQueue.AddJob())
using (var stream = job.JobStream)
stream.Write(bytes, 0, bytes.Length);
}
当然打印机工作正常,它不是默认打印机。 问题在于它什么都没打印。
如果我更改目标'打印机'这样:
PrintQueue printQueue = LocalPrintServer.GetDefaultPrintQueue();
它可以在默认打印机上打印。
如果我以这种方式询问打印队列列表,我将获得Zebra:
LocalPrintServer server = new LocalPrintServer();
PrintQueueCollection queueCollection = server.GetPrintQueues(new[] { EnumeratedPrintQueueTypes.Local });
foreach (PrintQueue pq in queueCollection)
Debug.WriteLine(pq.Name);
欢迎任何想法。