0

Windows Forms application, printing is done by creating process with command. I want to get error messages when printing fails, is this possible?

ProcessStartInfo info = new ProcessStartInfo(filePath)
{
    Arguments = "\"" + printerName + "\"",
    CreateNoWindow = true,
    WindowStyle = ProcessWindowStyle.Hidden,
    UseShellExecute = true,
    Verb = "PrintTo"
};
Process.Start(info);

Tried to use System.Printing.PrintSystemJobInfo to determine print outcome, but is not possible to determine from it, since it never get status IsCompleted. And print job disappears quickly.

Also tried to change print process to:

var printQueue = FindPrintQueue(printerName);
printQueue.Refresh(); 
PrintSystemJobInfo job = printQueue.AddJob(filePath, filePath, false);

But in this case printing job is created but the printing has the status "Spooling" and document is not printed at all.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Ramunas
  • 1,015
  • 1
  • 12
  • 19
  • Maybe the top rated answer [here](https://stackoverflow.com/questions/5001920/c-sharp-check-printer-status) will help? – Mikael Apr 01 '21 at 13:50
  • If you want interaction with the printing process, you should use the [PrintDocument](https://learn.microsoft.com/en-us/dotnet/api/system.drawing.printing.printdocument?view=net-5.0) functionality. – Mark Benningfield Apr 01 '21 at 14:04

0 Answers0