string strPath = @”h:\123.pdf”;
//var startInfo = new ProcessStartInfo(strPath);
//string verbToUse = “PrintTo”;
//startInfo.Verb = verbToUse;
//startInfo.Arguments = “FoxitPhantomPrinter”;
//Process p = Process.Start(startInfo);
//使用PrintTo可以使用startInfo.Arguments指定打印机
System.Drawing.Printing.PrintDocument pd = new System.Drawing.Printing.PrintDocument();
pd.DefaultPageSettings.PrinterSettings.PrinterName = “FoxitPhantomPrinter”;
Process processInstance = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.UseShellExecute = true;
startInfo.Verb = “PrintTo”;
startInfo.CreateNoWindow = true;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
//startInfo.FileName = strPath;
//startInfo.Arguments = @”\\127.0.0.1\FoxitPhantomPrinter”;
//startInfo.Arguments = @”/p /h \” + strPath + “\” \”” + pd.PrinterSettings.PrinterName + ” \””;//pd.PrinterSettings.PrinterName;
startInfo.Arguments = “FoxitPhantomPrinter”;
//startInfo.Arguments = “\”” + Printer + “\””;//可以防止空格
startInfo.FileName = strPath;
processInstance.StartInfo = startInfo;
processInstance.Start();