dibs487 dibs487 - 1 month ago 24
C# Question

PrintingDocument not printing to network printer, 0 byte document

this printing problem is driving me up the wall.

I have an automatic windows service that prints a document using PrintDocument that's suddenly stopped working. An MVC page for reprints that runs identical code works fine. There are no errors when it prints, the only clue I have is that I've turned on operational event logs on the print server and the 307 event says that I've sent a 0 byte file


Document 29, Print Document owned by WSAP_PON-WPAS24 on PON-WPAS24 was
printed on CHIEOL0011 through port _________. Size in bytes: 0.
Pages printed: 1. No user action is required.


when I reprint all the other events look the same but the size is 97355 bytes.

The drivers are identical the only difference is that the windows service is running in a different active directory domain to the print server whilst the web server is in the same domain but if there was some permissions issue wouldn't I have seen some errors somewhere? All boxes server 2012 r2.

Answer

I worked out what it was that was the difference between it working and it not. It was whether I was logged in to the server, when I was logged on it worked, when I wasn't it didn't. Got a more permanent fix by logging onto the box as the service account and using that to install the printer driver.

I'm not sure this will be of any use to anyone again.