且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C#如何打印word文档

更新时间:2023-10-27 23:38:34

据我所知,没有支持读取 word 格式和/或使用 .net 中的默认打印功能打印它的基本功能.

As far as I know there are no basic functions which support reading the word format and / or printing it with the default Print Functionality in .net .

如果您只想在没有任何进一步信息的情况下打印文档,您可以使用 启动方法 使用PrintTo动词

IF you just want to print the document without any further information you can start a basic windows print process by using the Start method of the Process Class with the PrintTo Verb

s.MSDN 论坛 c# 打印 Word 文档链接帖子的示例形式:

s. MSDN Forum Print Word Document in c# Example form the linkes post:

using (PrintDialog pd = new PrintDialog())
{
pd.ShowDialog();
ProcessStartInfo info = new ProcessStartInfo(@"D:\documents\filetoprint.doc");
info.Verb = "PrintTo";
info.Arguments = pd.PrinterSettings.PrinterName;
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(info);
}

如果您需要做更多(布局、其他数据...),您可以编写自己的 doc/docx 解析器或使用诸如 aspose 工具之类的东西

If you need to do more (layout, other data ...) you could write your own doc / docx parser or use something like the aspose tools

s.http://www.aspose.com/.net/word-component.aspx一个>

也许 infragistics/devexpress 也可能是读取 word 文档、将它们转换为 HTML 或进一步支持直接打印 word 的组件.

perhaps infragistics / devexpress may also components to read word documents, convert them to HTML or furthermore supporting direct printing of the word.

对于所有工具,试用版都应该可用

For all tools trial versions should be aviable

http://www.infragistics.com

https://www.devexpress.com/