public void PrintPDFs(string pdfFileName, bool OpenCash = false) { PrintingThreadObjects firstThreadObject = new PrintingThreadObjects(); firstThreadObject.Name = pdfFileName; Thread PrintThread = new Thread(PrintingThreadFunc); PrintThread.Start(firstThreadObject); }
private void PrintingThreadFunc(object parameter) { PrintingThreadObjects threadObject = parameter as PrintingThreadObjects; try { Process proc = new Process(); //proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; // proc.StartInfo.Verb = "print"; //Define location of adobe reader/command line //switches to launch adobe in "print" mode PrinterSettings settings = new PrinterSettings(); proc.StartInfo = new ProcessStartInfo(threadObject.Name); proc.StartInfo.Arguments = settings.PrinterName; proc.StartInfo.Verb = "print"; proc.StartInfo.CreateNoWindow = true; proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; // proc.StartInfo.FileName = threadObject.Name;// @"C:\Program Files (x86)\Foxit Software\Foxit Reader\Foxit Reader.exe"; // @"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"; // proc.StartInfo.Arguments = string.Format(@"-p"); proc.Start(); //proc.StartInfo.UseShellExecute = false; //proc.StartInfo.CreateNoWindow = true; //proc.StartInfo.Arguments = String.Format(@"/p /h {0}", threadObject.Name); //proc.Start(); //proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; if (proc.HasExited == false) { proc.WaitForExit(10000); } //proc.EnableRaisingEvents = true; //proc.Close(); //KillAdobe("AcroRd32"); threadObject.Result = "Done Successfully"; resultValue(threadObject); } catch (Exception ex) { threadObject.Result = "Thread Error! {EXCEPTION}\n" + ex.Message; resultValue(threadObject); } }
void resultValue(PrintingThreadObjects threadObject) { // MessageBox.Show("Thread Name : " + threadObject.Name + " Thread Result : " + threadObject.Result); }