cpo*_*ign 5 c# windows printing
我有一个代码,我打印word文档.在示例文档中,有一个带有图片的部分,用户修改了边距.
当我执行代码时,我收到以下消息:
第1部分的边距设置在可打印区域之外.
处理文档后,它开始假脱机并抛出此promt
如何关闭通知对话框?
我的代码到目前为止:
Process printJob = new Process();
printJob.StartInfo.Verb = "PrintTo";
printJob.StartInfo.Arguments = printerName;
printJob.StartInfo.ErrorDialog = false;
printJob.StartInfo.CreateNoWindow = true;
printJob.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
printJob.StartInfo.FileName = path;
printJob.StartInfo.UseShellExecute = true;
printJob.StartInfo.Verb = "print";
printJob.Start();
Run Code Online (Sandbox Code Playgroud)
其中variable path>是文件名路径
http://word.mvps.org/faqs/macrosvba/OutsidePrintableArea.htm
根据这个,你需要关闭后台打印,然后关闭Application.DisplayAlerts.
编辑
你无法做到这一点Process."print"动词使用/ x/dde告诉Word打印:
/ x从操作shell启动Word的新实例(例如,在Word中打印).此Word实例仅响应一个DDE请求,并忽略所有其他DDE请求和多实例.如果要在操作环境中启动Word的新实例(例如,在Windows中),建议您使用/ w开关,它将启动功能完整的实例.
要取消消息,您需要进行互操作:
Print(string path)方法:Application wordApp = new Application();
wordApp.Visible = false;
//object missing = Type.Missing;
wordApp.Documents.Open(path); //for VS 2008 and earlier - just give missing for all the args
wordApp.DisplayAlerts = WdAlertLevel.wdAlertsNone;
wordApp.ActiveDocument.PrintOut(false); //as before - missing for remaining args, if using VS 2008 and earlier
wordApp.Quit(WdSaveOptions.wdDoNotSaveChanges); //ditto
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3393 次 |
| 最近记录: |