I have seen this question which was closed as a duplicate to this question. Unless I am misunderstanding the answers neither question has a valid solution for me.
I am trying to create POS style printing. My requirements seem simple.
Send to thermal printer(RawPrinterHelper)- Validate print job success (?)
Send to backup printer if failed or in que too long.(RawPrinterHelper)
For the first and third points I have resorted to the RawPrinterHelper. It works great but SendStringToPrinter
will always return true as long as the printer is installed. Even if the printer is not setup correctly and can never finish the print job. I don't think I can used the RawPrinterHelper for validation.
The questions linked above use the ManagementObjectSearcher on the Win32_PrintJob
to poll for information about the print jobs. I have also used the ManagementEventWatcher on the Win32_PrintJob
to poll for new and deleted print job events. These solutions work for validating print jobs in most scenarios, but rarely thermal printers (total pages can't be relied on). Polling for information to validate printjobs doesn't seem like the best option. I was easily able to miss the information printing test pages.
For these reasons, the ManagementObjectSearcher and ManagementEventWatcher won't do the trick for me either.
The only solid solution I can seem to find is by Duncan Edwards Jones here. Thanks by the way if you come across this I've learned a lot from you. Duncan shows how to use the FindFirstPrinterChangeNotification
to get events about the job status. I have tested this and I can say it works nicely for validating if a print job was successfully printed when it was removed from the print que.
Although Duncans solution is great I would need to go through it and make it x64 compatible with my project and probably do quite a bit more learning and understanding to get it into c#.
Is Duncans method of using FindFirstPrinterChangeNotification still the appropriate way to determine if a print job left the que successfully?
Part of me feels like I'm working too far back in time and .NET must have a solution for this problem now.
Update: It will be a requirement for the end user to have the printer installed and test page functioning from within windows. I won't support anything windows doesn't recognize.