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

跟風遠走 提交于 2021-01-27 05:33:11

问题


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!


回答1:


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.




回答2:


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.




回答3:


Call the PrintOut() method of the Microsoft.Office.Interop.Word.Document object with ManualDuplexPrint parameter set to true.



来源:https://stackoverflow.com/questions/9467412/office-interop-word-how-to-print-the-document-on-both-sides

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!