private void print() { ProcessStartInfo infoPrintPdf = new ProcessStartInfo(); string pathPdf = @"E:\eSAFE\FileStore\PDF\Account Statement_76876876878_040111_000018473018_20160620172958468.pdf"; infoPrintPdf.FileName = pathPdf; // The printer name is hardcoded here, but normally I get this from a combobox with all printers string printerName = @"\\10.15.0.8\NTP Printer 001 SecondFloor"; //string printerName = "HP LaserJet Professional P1606dn"; string driverName = "hp1100sd.dll"; string portName = "10.15.0.23"; infoPrintPdf.FileName = @"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"; 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)