Reputation: 3996
I want to build a Windows Service in C# which listens to an MSMQ queue for incoming print command messages. A message references a PDF document und contains the name of the destination printer (and maybe some other metadata like numbers of copies to print). The service should pick up the PDF and print it on the destination printer.
Question: Is it possible to print an arbitrary PDF on a printer from a Windows Service?
supplement:
The implementation should not depend on Acrobat Reader or any other "GUI tool". The Windows service runs headless. Besides I want to avoid to start a separate process for each print job when this is possible.
Upvotes: 3
Views: 3756
Reputation: 1152
I use Spire.PDF library. The free version has a limit of 10 pages per file. No UI or Acrobat dependence
https://www.nuget.org/packages/Spire.PDF/
PdfDocument pdfdocument = new PdfDocument();
pdfdocument.LoadFromFile(path);
pdfdocument.PrinterName = printername;
pdfdocument.PrintDocument.PrinterSettings.Copies = copiesNumber;
pdfdocument.PrintDocument.Print();
pdfdocument.Dispose();
Upvotes: 3