如何从C#打印Word文档

时间:2009-06-20 15:22:08

标签: c# .net printing ms-word

如何从C#.NET应用程序启动文档打印? Word文档已存在于硬盘驱动器中。我只想在按钮点击事件上开始打印Word文档。

2 个答案:

答案 0 :(得分:8)

 ProcessStartInfo psi = new ProcessStartInfo(wordFilename)
 {
    UseShellExecute = true,
    Verb = "print",
    RedirectStandardOutput = false,
    CreateNoWindow = true
 };

 using (Process p = new Process {StartInfo = psi})
 {
     p.Start();
     p.WaitForExit();
 }

答案 1 :(得分:2)

要执行此类有关System.Diagnostics.Process的操作,MSDN页面将显示如何将Word文档作为示例进行处理。简短版本:

 System.Diagnostics.Process printProcess = new System.Diagnostics.Process();
 printProcess.StartInfo.FileName = @"X:\test\print this.doc";
 printProcess.StartInfo.Verb = "Print";
 printProcess.StartInfo.CreateNoWindow = true;
 printProcess.Start();