Print word document without showing print processing dialog

We have already demonstrated how to print word documents with the method PrintDocument offered by Spire.Doc. With this method, you may find that you get the print processing dialog every time.

Print word document without showing print processing dialog

To avoid the print processing dialog from appearing, Spire.Doc offers you a solution to add a property to specify a standard print controller to hide the print processing dialog. This article will show you clearly how to print word documents without invoking Print Dialog. Here comes to the details.

Step 1: Create a new word document and load from file.

Document doc = new Document();
doc.LoadFromFile("sample.docx");

Step 2: Get the PrintDocument object.

PrintDocument printDoc = doc.PrintDocument;

Step 3: Add the property PrintController to specify a standard print controller to hide the print processing dialog.

printDoc.PrintController = new StandardPrintController();

Step 4: Print the word document.

printDoc.Print();

After you debug it, the word document will be print without showing the print processing dialog.

Full codes:

private void button1_Click(object sender, EventArgs e)
{
    Document doc = new Document();
    doc.LoadFromFile("sample.docx");

    PrintDocument printDoc = doc.PrintDocument;

    printDoc.PrintController = new StandardPrintController();

    printDoc.Print();
}