C# 使用 Process.Start 打印文档而不显示 Word
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/751065/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using Process.Start to print documents without showing Word
提问by Matt
I am using the following code to print a word document from a C# app.
我正在使用以下代码从 C# 应用程序打印 Word 文档。
ProcessStartInfo info = new ProcessStartInfo(myDocumentsPath);
info.Verb = "Print";
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(info);
This works fine Word opens and prints the document, and then closes itself down. The issue is that Word opens visibly, despite CreateNoWindow = true, and WindowsStyle =Hidden. I would have expected these two settings to mean that Word opened silently.
这工作正常 Word 打开并打印文档,然后自行关闭。问题在于,尽管 CreateNoWindow = true 和 WindowsStyle =Hidden,但 Word 仍能明显打开。我原以为这两个设置意味着 Word 以静默方式打开。
EDIT: Please don't suggest Word object model automation - I have many different document types that need to be printed (PDF etc) - it is just Word docs that are causing the issue at the moment.
编辑:请不要建议 Word 对象模型自动化 - 我有许多不同的文档类型需要打印(PDF 等) - 目前只是 Word 文档导致了问题。
Any thoughts?
有什么想法吗?
TIA
TIA
Matt
马特
采纳答案by Ed Guiness
Word is free to ignore (and apparently does ignore) your request that it remain hidden.
Word 可以随意忽略(并且显然确实忽略了)您要求它保持隐藏状态的请求。
See also Why is my hidden process still visible?
另请参阅为什么我的隐藏进程仍然可见?