How can I launch the print of a document from C# .NET application ? the word document already exists in the hard drive. I just wish to start printing that word document upon the button click event.
+5
A:
ProcessStartInfo psi = new ProcessStartInfo(wordFilename)
{
UseShellExecute = true,
Verb = "print",
RedirectStandardOutput = false,
CreateNoWindow = true
};
using (Process p = new Process {StartInfo = psi})
{
p.Start();
p.WaitForExit();
}
Chris Doggett
2009-06-20 15:40:38
You need to add `p.WaitForExit()` (I think), but otherwise this is the right way to do it.
Noldorin
2009-06-20 15:43:35
@Noldorin: Thanks. That would've solved my problem with it closing the form before printing on this question: http://stackoverflow.com/questions/878878/webbrowser-control-wont-print-from-c
Chris Doggett
2009-06-20 15:45:16
Ah, well I'm glad I've answered another question at least. :)
Noldorin
2009-06-20 15:57:20