0

I have the following code:

var server = new LocalPrintServer();
var queue = server.DefaultPrintQueue;
var job = queue.AddJob("Test job");
var stream = job.JobStream;
var bytesToWrite = Encoding.Unicode.GetBytes("Hello World!");
stream.Write(bytesToWrite, 0, bytesToWrite.Length);
stream.Close();

When I call stream.Close() Windows informs, that it sended job to printer, but nothing happens. I opened "Devices and printers", selected default printer, checked its queue, and saw my job there. It had status Printed, Pages: N/A, and empty size.

What I am doing wrong?

PS: .NET Framework 4.5

PPS: Printer works normally, I can easily print any pdf or word document.

  • I doubt this will change anything, but you should try `Flush`ing the stream before closing. – Jashaszun Aug 01 '14 at 16:43
  • If you have access to other printers, could you check if one of them works? The PrintQueue.AddJob MSDN page (http://msdn.microsoft.com/en-us/library/ms552913(v=vs.110).aspx) has an example similar to yours, and says "This code only works with printers that can detect and print plain text. Some of them cannot." – raj Aug 01 '14 at 17:29

0 Answers0