Friday, 5 February 2016

Windows Service application unable to send print job

I've been trying to send print job into a remote printer via a Windows Service application in a few different ways: 

  • .Net PrintDocument class
  • a third party library (on-demand printing)
  • ghost script + ghostview
however I was not successful. I found out that Windows Service doesn't allow you or doesn't easily allow you to send or create a print job at all for security reasons or for any reasons. See posts:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms683502.aspx

http://stackoverflow.com/questions/15834064/printing-from-windows-service-on-windows-8-fails

Well another day past and some lost hairs (due to hair pulling) I found a web post about a utility class that creates a "Raw" print job and I thought it may work because Windows won't treat it as calling or executing another windows app or windows process which the Windows Service doesn't like to do. So I give it a go and it works! See the section of the page where it says "2. Mit VB.Net RAW-Daten an den Drucker senden" which translate to "Send With VB.Net RAW data to the printer". (Note: The website is in german language. Thank you Germany!)

http://www.vbarchiv.net/tipps/tipp_2375-kassenbon-drucker-mit-vbnet-oder-c-per-esc-pos-befehle-ansprechen.html

No comments:

Post a Comment