C# word打印文档打印不全(数据为完全发送至打印机,程序已经退出)

我们在调用word打印的时候有时候出现过这种情况。即,我们调用wordDoc.PrintOut把数据发送给打印机后,调用关闭程序的方法,有时候会出现数据未完全发送给打印机造成数据丢失页面打印不全的问题。

解决办法:强制让程序把数据全部发给打印机后在关掉结束掉打印进程。

object wdpa = WdPrintOutRange.wdPrintAllDocument;
                object wdItem = WdPrintOutItem.wdPrintDocumentContent;
                object wdPageType = WdPrintOutPages.wdPrintAllPages;
                object background = false;

                wordApp.PrintOut(ref background, ref Nothing, ref wdpa, ref Nothing,
                    ref Nothing, ref Nothing, ref wdItem, ref Nothing,
                    ref Nothing, ref wdPageType, ref Nothing, ref Nothing,
                    ref Nothing, ref Nothing, ref Nothing,
                    ref Nothing, ref Nothing, ref Nothing, ref Nothing);

其上可以解决

原文地址:https://www.cnblogs.com/chenbg2001/p/2036599.html