ProcessStartInfo infoPrintPdf = new ProcessStartInfo(); //pathPdf = @"D:\ITC.pdf"; infoPrintPdf.FileName = pathPdf; // The printer name is hardcoded here, but normally I get this from a combobox with all printers string printerName = System.Configuration.ConfigurationManager.AppSettings["PrinterName"].ToString(); //string printerName = "HP LaserJet Professional P1606dn"; string driverName = System.Configuration.ConfigurationManager.AppSettings["DriverName"].ToString(); string portName = System.Configuration.ConfigurationManager.AppSettings["portName"].ToString(); string passwordStr = "july2016."; //System.Security.SecureString password = new System.Security.SecureString(); //foreach (char c in passwordStr) // password.AppendChar(c); //infoPrintPdf.UserName = "veena.cjohn@chn.nestgroup.net"; //infoPrintPdf.Password = password; infoPrintPdf.FileName = System.Configuration.ConfigurationManager.AppSettings["AcrobatExePath"].ToString(); infoPrintPdf.Arguments = string.Format("/t {0} \"{1}\" \"{2}\" \"{3}\"", pathPdf, printerName, driverName, portName); infoPrintPdf.CreateNoWindow = true; infoPrintPdf.UseShellExecute = false; infoPrintPdf.WindowStyle = ProcessWindowStyle.Hidden; Process printPdf = new Process(); printPdf.StartInfo = infoPrintPdf; printPdf.Start(); // This time depends on the printer, but has to be long enough to // let the printer start printing System.Threading.Thread.Sleep(10000); if (!printPdf.CloseMainWindow()) // CloseMainWindow never seems to succeed printPdf.Kill(); printPdf.WaitForExit(); // Kill AcroRd32.exe printPdf.Close(); // Close the process and release resources
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)