foreach (var x in fileList) { // Printing files through IE on default printer. Console.WriteLine("{0}", x); SHDocVw.InternetExplorer IE = new SHDocVw.InternetExplorer(); IE.DocumentComplete += new SHDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler(IE_DocumentComplete); IE.PrintTemplateTeardown += new SHDocVw.DWebBrowserEvents2_PrintTemplateTeardownEventHandler(IE_PrintTemplateTeardown); IE.Visible = true; IE.Navigate2(x); while (IE.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE) { System.Windows.Forms.Application.DoEvents(); } } } } } static void IE_PrintTemplateTeardown(object pDisp) { if (pDisp is SHDocVw.InternetExplorer) { SHDocVw.InternetExplorer IE = (SHDocVw.InternetExplorer)pDisp; IE.Quit(); System.Environment.Exit(0); } } static void IE_DocumentComplete(object pDisp, ref object URL) { if (pDisp is SHDocVw.InternetExplorer) { SHDocVw.InternetExplorer IE = (SHDocVw.InternetExplorer)pDisp; IE.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, 2); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)