0

My users print files (PDF,docx etc...) in apps like word, excel or e.g ERP Systems from different printers on there Computers. I need to copy this files to a specific folder to save them in a storage.

This is my current code.

using System.Management;

bool NewPrintJob = false;
string wmiQuery = "SELECT * FROM Win32_PrintJob";
ManagementObjectSearcher jobsSearcher = new 
ManagementObjectSearcher(wmiQuery);
ManagementObjectCollection jobCollection = null;
List<PrintJob> printJobs = new List<PrintJob>();
while (!NewPrintJob)
{
    jobCollection = jobsSearcher.Get();
    NewPrintJob = jobCollection.Count > 0; //New Print Job?
}

EDIT

But how can I access the document to save it to a folder in the file format that the user has selected when printing?

The developmentlanguages dont need to be C# or C++.

Cazzador
  • 33
  • 2
  • 9
  • Please define "correct fileformat". – Nick Westgate Nov 08 '17 at 02:21
  • @NickWestgate E.g the user write a text in word and print it as a pdf file. In this case is my target to get a file in the pdf format. – Cazzador Nov 10 '17 at 03:58
  • This would be an extraordinarily difficult task, bordering on impossible. First, you would have to develop a custom port monitor or print processor, which are non-trivial tasks. Then you would need to attach that port monitor or print processor to every printer your users use. Some printers require their own port monitors or print processors, so yours would probably render those printers non-functional. – Carey Gregory Dec 02 '17 at 01:31
  • @CareyGregory Okay i never thought it would be so difficult. Currently i found a Software for converting documenttypes to PDF. So i habe zu write a Custom printprozessor or portmonitor. Which one of this two would you prefer dir this task? Can you also prefer some online tutorials for this development? – Cazzador Dec 09 '17 at 11:57
  • I don't think you fully understand the Windows printing architecture yet. A print processor or port monitor doesn't receive the file being printed (if it's a file at all). A print processor receives the spool file contents, which is a modified form of EMF, while a port monitor receives the output from the print driver associated with that printer. Neither of these data streams can be converted directly to PDF. Sorry, there are no online tutorials I know of. Download the Windows Driver Kit and start with the documentation and samples there. – Carey Gregory Dec 09 '17 at 16:46

0 Answers0