0

Quick summary

I am able to print out a Word document in C# using PrintOut() function like so:

        object missing = Type.Missing;
        Word.Application app = new Word.Application();
        Word.Document doc = null;
        object template = @"/path/Template.docx";
        doc = app.Documents.Open(template, ReadOnly: true);
        app.Visible = false;

        // Print here
        doc.PrintOut();

Problem

What I realized is I can't print the document on both pages, if there are 2 pages. The 2 pages print 2 sheets, instead of printing on both sides.

I had a look here: https://learn.microsoft.com/en-us/office/vba/api/Word.Document.PrintOut nowhere it says anything about Printing on Both sides.

Question

What is a good method to print a Word.Document in C# on both sides of paper?

Eduards
  • 1,734
  • 2
  • 12
  • 37
  • The document you linked to suggests you might be able to use `ManualDuplexPrint` if the step of manually flipping the paper works for you - ie if your printer doesn't _really_ support two sided printing. – James Thorpe Jan 07 '21 at 13:37
  • You could take a look at [this question](https://stackoverflow.com/questions/9467412/office-interop-word-how-to-print-the-document-on-both-sides). – Jacob Lockard Jan 07 '21 at 13:37
  • @JamesThorpe Yeah, already tried that. Trying to make it simple as possible. – Eduards Jan 07 '21 at 13:38
  • 1
    Looks like there's an approach [documented here](https://learn.microsoft.com/en-us/archive/blogs/vsod/how-to-set-duplex-printing-for-microsoft-word-automation-clients-in-c-vb-net) - essentially you need to set the printer driver setting before doing what you're already doing above. – James Thorpe Jan 07 '21 at 13:42
  • @JamesThorpe Thanks for that, I'll try it out now. – Eduards Jan 07 '21 at 13:44
  • @JamesThorpe Would you know what `using` reference is used to find `DuplexSettings`? – Eduards Jan 07 '21 at 13:46
  • It's some custom code included in a zip file attached to that blog post - essentially all the win32 API calls to work with the driver are packaged up in that class – James Thorpe Jan 07 '21 at 13:47
  • Here? https://support.microsoft.com/kb/828638 404 Page Not Found if thats the one you are referring to. – Eduards Jan 07 '21 at 13:49
  • No, down at the bottom - _"[PrinterDuplexSettings.zip](https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/30/70/74/PrinterDuplexSettings.zip)"_ – James Thorpe Jan 07 '21 at 13:49
  • 1
    @JamesThorpe Ahh I see.. Also in the meantime I will test this https://stackoverflow.com/a/10142376/12485722 – Eduards Jan 07 '21 at 13:50

1 Answers1

0

It should be a setting you can change in the physical printer if that doesn't work try calling the PrintOut() method of Microsoft.Office.Interop.Word.Document object with ManualDuplexPrint parameter set to true.

Caio Navarro
  • 48
  • 1
  • 13