I have some code that prints a document using the System.Drawing.Printing
namespace. This now needs to be moved into a windows service. The documentation states that this is not possible, which would support my findings so far (in that it doesn't work). I'm working under the assumption that I can get this to work by using the System.Printing
namespace instead.
Here is the code that I have so far:
private Metafile myDoc;
myDoc = GetEmfDoc();
PrintServer ps = new PrintServer("\\server1\printer1");
EnumeratedPrintQueueTypes[] flags = { EnumeratedPrintQueueTypes.Local };
PrintQueueCollection queues = ps.GetPrintQueues(flags);
PrintQueue pq = queues.First<PrintQueue>();
pq.AddJob("JobName", ?);
So I want to pass myDoc
to pq.AddJob()
, but this doesn't seem to be possible. Using System.Drawing.Printing
it was possible to simply render this on a page by page basis in the PrintDocument.PrintPage
event.
Is what I'm trying to do possible, and if so, could someone point me in the right direction?