I have created Print spooler application to print pdf asynchronously.
(Application uses veryPDF command to print from network printer)
Here is Code
var procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", " /c" + "E:\pdfprint_cmd\pdfprint.exe -$ 388444444448350FA394 E:\PrintSpoolerApplication\PrintSpoolerApplication\bin\Debug\45940.pdf");
procStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
procStartInfo.Verb = "runas";
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
var proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
proc.WaitForExit();
// Some stuff
But It did not Wait on WaitForExit code. It did executing (here //Some stuff) even if my document is in printer queue.
Is there any other way that notify when printing is done?
Your code waits for cmd.exe
to finish, which (probably) terminates immediately after it has started pdfprint.exe
as a child process. I suggest you
pdfprint.exe
directly (why do you need the Windows command line here anyway?)However, both approaches only work if pdfprint.exe
actually waits for the scheduled print job to be completed. I don't know the tool, so I have no idea if it behaves that way. If it doesn't, you would have to access the print queue, which (as pointed out by Hans in his comment) is not recommended.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With