0

I want to create a windows form application that will sit on our local server and print invoices to a network printer say every 30 minutes.

Can someone confirm that you definitely can't use a console application to print (invoices will include images for logos etc). The reason I ask is that it seems pointless to have a GUI when there's no need for one. If it can, a simple resource to get me going would be great.

Also I can't seem to find an easy to follow tutorial on .net printing basics (positioning data etc). A the moment the whole concept isn't sinking in at all!

DOK
  • 32,337
  • 7
  • 60
  • 92
ComfortablyNumb
  • 1,448
  • 10
  • 37
  • 64
  • For precise details about printing, you need to start with the document type. Are you printing Word documents, text files, PDFs or something else? – DOK Nov 16 '11 at 14:31
  • Sorry, should have made that bit clearer. I want to draw data from a database - ie order number, billing address, orderlines etc. – ComfortablyNumb Nov 16 '11 at 14:36

2 Answers2

0

If you don't need a UI, perhaps a .Net Windows service will do the job. I have used this method before for exactly this purpose -- every n minutes, it looks for something to print, either in a folder or a database table.

If you choose this route, here is one of many helpful online tutorials you could use.

DOK
  • 32,337
  • 7
  • 60
  • 92
  • 2
    Microsoft strongly recommends to *not* use a service to do printing. Trouble-makers are printer drivers, they often expect to be able to display a UI and spam the user for things like replacing half-empty toner cartridges. Doesn't work well in a service, nobody can see the window. Printing just stops without anyway to diagnose why. – Hans Passant Dec 05 '11 at 15:21
  • 1
    @Hans Passant: Good points. I guess choosing the right tool depends on the situation. In a very large corporation, I have successfully written services to print large volumes of form letters from remote printers. There was no need for a person to sit at a console monitoring the job, which ran more-or-less continually all day and into the night. Decent logging of errors -- including email notification if desired -- can handle the issue of no UI. With much less print volume, a console app might definitely be preferable. That gives control over the timing of the print job. – DOK Dec 05 '11 at 16:37
-1

I don't see why a console app would be out of the question, you can use all the same libraries that a WinForms app can. If you are simply pulling data from the database, any number of ways could be used to generate documents. If you wanted to get fancy, you could even produce a 'nicely' formatted document using GDI+ objects and plug in your values. As long as your producing your documents in the background, it doesn't really matter if you have a Window available to preview(though it may be wise to have some hidden debugging tools.)

I also agree with the above post that a windows service may be your best bet.

Lee Harrison
  • 2,306
  • 21
  • 32