C#:打印出Word文档而不提前保存document.PrintOut()

C#: print out Word document without saving it in advance document.PrintOut()

我想打印一个Word文档,但不预先保存。这可能吗?

//I created an instance for word app  
Microsoft.Office.Interop.Word.Application winword = new Microsoft.Office.Interop.Word.Application();

//I created a Word document (including pararaphs and tables):
Microsoft.Office.Interop.Word.Document document = winword.Documents.Add(ref missing, ref missing, ref missing, ref missing);

//I can print the document, if I save it before. But I want to print it without saving the word document.
document.SaveAs2(@"C:\User\Desktop\Test");
document.PrintOut()

//Export of the document as pdf-file. 
document.ExportAsFixedFormat(label24.Text + "Document" + textBox13.Text, WdExportFormat.wdExportFormatPDF, true);

如果问题是文档在打印作业完成之前关闭,那么最好的方法是关闭后台打印,至少在代码执行期间。

winword.Options.PrintBackground = false;

后台打印的引入是为了允许用户在处理打印作业时继续工作。这对用户来说很好,但是对于问题中的代码来说是个问题。