public class Pdf { public Boolean PrintPDFs(string pdfFileName) { try { ProcessStartInfo info = new ProcessStartInfo(); info.Verb = "print"; info.FileName = pdfFileName; info.CreateNoWindow = true; info.WindowStyle = ProcessWindowStyle.Hidden;
Process p = new Process(); p.StartInfo = info; p.Start();
System.Threading.Thread.Sleep(10000); if (false == p.CloseMainWindow()) { KillAdobe("AcroRd32"); } return true;
} catch (Exception ex) { File_operations logDetail = new File_operations(); logDetail.WriteToLogFile(ex.Message); return false; } } private static bool KillAdobe(string name) { foreach (Process clsProcess in Process.GetProcesses().Where( clsProcess => clsProcess.ProcessName.StartsWith(name))) { clsProcess.Kill(); return true; } return false; } }