简体   繁体   中英

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

I print documents (batch print) using Word.Document.PrintOut method. 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.

Word 2010, C#, .NET 3.5


Many thanks to John for his answer (+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. 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 :)
  2. After the failure of the DocumentProperties API I tried to put the print commands and got the following results:

    • 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...
    • Clients printer ( Xerox 3600 ) apparently was "not fully HP-compatible" and did not print on both sides at all!

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. It is VB code, but it should be pretty easy to convert to 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. 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. A full list of PCL print commands are available from a Microsoft KB article.

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()方法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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