C# 调用Word(PrintOut) 直接打印,出现“第一节的页边距设于可打印区域之外,是否继续”
/// <summary>
/// 输出到打印机
/// </summary>
public void Print()
{
//不弹出警告框,主要针对“第一节的页边距设于可打印区域之外,是否继续”
_wordApp.Options.PrintBackground = false;//主要是加上这一代码,网上很多都没有。导致仍然弹出警告
_wordApp.DisplayAlerts = WdAlertLevel.wdAlertsNone;
object missing = System.Reflection.Missing.Value;
_wordDoc.PrintOut(ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
//警告复原
_wordApp.Options.PrintBackground = true;
_wordApp.DisplayAlerts = WdAlertLevel.wdAlertsAll;
}