How to Print Word Document in C#

In this step by step tutorial, we’ll elaborate how to print Word document in C# without interop and without automation. We’ll use Windows Forms application to print Word DOCX in C# using a printer dialog.

Steps to Print Word Document in C# Without Interop

  1. Install Aspose.Words for .NET package from NuGet.org
  2. Add reference to Aspose.Words and Aspose.Words.Rendering namespaces
  3. Set license of Aspose.Words for .NET using SetLicense method
  4. Create a new Document object and load DOCX document
  5. Create a new PrintDialog object and set printer dialog properties
  6. Create PrintPreviewDialog object and set AsposeWordsPrintDocument object and other properties
  7. Attach event to activate the printer dialog
  8. Finally, show the printer dialog to the user

In the above steps, we’re loading Word document into Document object, setting properties of the printer dialog and then passing the document to the created printer dialog instance. These steps help print Word document in C# using a windows printer dialog. We’ll add a separate how-to topic, to show how to print Word document without a printer dialog.

Code to Print Word Document in C# Without Automation

The above code in C# print Word document without opening the DOCX or DOC file itself. It sets the properties of the print dialog along with passing the document itself and then let the user print the document.

 English