如何从 C# 打印 Word 文档

发布于 2024-07-24 08:28:49 字数 74 浏览 2 评论 0原文

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦里人 2024-07-31 08:28:49
 ProcessStartInfo psi = new ProcessStartInfo(wordFilename)
 {
    UseShellExecute = true,
    Verb = "print",
    RedirectStandardOutput = false,
    CreateNoWindow = true
 };

 using (Process p = new Process {StartInfo = psi})
 {
     p.Start();
     p.WaitForExit();
 }
 ProcessStartInfo psi = new ProcessStartInfo(wordFilename)
 {
    UseShellExecute = true,
    Verb = "print",
    RedirectStandardOutput = false,
    CreateNoWindow = true
 };

 using (Process p = new Process {StartInfo = psi})
 {
     p.Start();
     p.WaitForExit();
 }
深居我梦 2024-07-31 08:28:49

要执行此类操作,您需要了解 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();

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();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文