How to print a Word document from C#

后端 未结 2 934
野性不改
野性不改 2021-01-28 21:03

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

相关标签:
2条回答
  • 2021-01-28 21:46

    To do this kind of thing you need to know about System.Diagnostics.Process , the MSDN page shows how to pridnt a Word document as an example. A short version:

     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();
    
    0 讨论(0)
  • 2021-01-28 21:50
     ProcessStartInfo psi = new ProcessStartInfo(wordFilename)
     {
        UseShellExecute = true,
        Verb = "print",
        RedirectStandardOutput = false,
        CreateNoWindow = true
     };
    
     using (Process p = new Process {StartInfo = psi})
     {
         p.Start();
         p.WaitForExit();
     }
    
    0 讨论(0)
提交回复
热议问题