简体   繁体   English

Office.Interop.Word - 如何在两面打印文档?

[英]Office.Interop.Word - How to print the document on both sides?

I print documents (batch print) using Word.Document.PrintOut method. 我使用Word.Document.PrintOut方法打印文档(批量打印)。 How can I print a document on both sides? 如何在两面打印文档?

In the MS Word interface it can be done through the File -> Print -> Print on Both Sides option. MS Word界面中,可以通过文件 - > 打印 - > 双面打印选项来完成。

Word 2010, C#, .NET 3.5 Word 2010,C#,.NET 3.5


Many thanks to John for his answer (+1)! 非常感谢John的回答(+1)! There are results of my research: 有我的研究结果:

  1. I went to the first path that John recommends, found a few additional articles, like "classic" article on CodeProject ( Changing printer settings using C# ) and several others derived from it. 我去了John推荐的第一条路径,发现了一些额外的文章,比如CodeProject上的“经典”文章( 使用C#更改打印机设置 )和其他几个文章 In the end, I got compiled code which was to set a Duplex property, but like many others "victims" of this article - this code did not work :) 最后,我得到了编译代码,这是设置一个Duplex属性,但像本文的许多其他“受害者” - 这段代码不起作用:)
  2. After the failure of the DocumentProperties API I tried to put the print commands and got the following results: DocumentProperties API失败后,我尝试放置打印命令并得到以下结果:

    • My office printer ( Kyocera FS-C5100 ) successfully printed a document on both sides, BUT came crazy and began to print each paragraph on a separate sheet... 我的办公打印机( Kyocera FS-C5100 )成功地在两面打印了一份文件,但是疯了,开始在另一张纸上打印每一段...
    • Clients printer ( Xerox 3600 ) apparently was "not fully HP-compatible" and did not print on both sides at all! 客户端打印机( Xerox 3600 )显然“不完全与HP兼容”,并且根本不打印两面!

So my investigation continues and if anyone have other ideas - welcome! 所以我的调查仍在继续,如果有人有其他想法 - 欢迎!

There is a Microsoft KB Article on HOWTO: Set Duplex Printing for Word Automation , unfortunately it is not a simple property you set. 有关HOWTO的Microsoft知识库文章:为Word Automation设置双面打印 ,遗憾的是它不是您设置的简单属性。 It is VB code, but it should be pretty easy to convert to C#. 它是VB代码,但转换为C#应该很容易。

If you know you are using a PCL compatible printer, you can use print commands inside the document to force it to be duplex. 如果您知道使用的是PCL兼容打印机,则可以在文档中使用打印命令强制它为双面打印机。 This is really helpful when you need to switch between simplex and duplex mid document. 当您需要在单面和双面中间文档之间切换时,这非常有用。 You can add a field to the header of the document and then use 27"&l1S" or 27"&l2S" for duplex long and duplex short respectively. 您可以在文档的标题中添加一个字段,然后分别使用27“&l1S”或27“&l2S”表示双工长和双工短路。 A full list of PCL print commands are available from a Microsoft KB article. Microsoft知识库文章中提供了完整的PCL打印命令列表

The problem can not been solved directly, but it is possible to implement a workaround. 问题无法直接解决,但可以实施解决方法。

One "physical" printer should be installed on the client system several times, so that in the printers list it should be listed twice under different names. 应在客户端系统上多次安装一台“物理”打印机,以便在打印机列表中以不同的名称列出两次。

Further, one of these "printers" must be configured to double side printing, and second to normal - one side printing. 此外,这些“打印机”中的一个必须配置为双面打印,其次是正常打印 - 单面打印。 Depending on the application needs it selects one of two "printers" for printing documents. 根据应用程序的需要,它选择两个“打印机”之一来打印文档。

在ManualDuplexPrint参数设置为true的情况下,调用Microsoft.Office.Interop.Word.Document对象的PrintOut()方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM