I am writing a console application in .Net Framework 4.8 that will run as a Windows service. It should be possible in this console application to send a file to a printer (installed on the same pc as where the Windows service is running). However I find this quite challenging and haven't found a suitable solution. I have no control about what else is installed on the pc (for instance Adobe Acrobat Reader). The following things I already tried are:
- Using the PrintDocument class from .net (this seems to be for creating the content of what needs to be printed at runtime not for already existing files)
- Using System.Printing (this can't be used for windows services as stated in their documentation here)
- using a process with verb 'print' and 'printto' as described in this Stack overflow post
- I ended up using this Nuget package. Which works for .txt and .pdf but not for .docx files for instance. I would like to be able to print different sorts of files.
What am I doing wrong? I would think this is straight forward but apparently not. Which makes me think I am looking at it from the wrong angle so to speak. Are there any examples available or Nuget packages to help me achieve this? If you need any other information, please ask me.