ProcessStartInfo打印并指定打印机

  • Post author:
  • Post category:其他


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();



版权声明:本文为zhangdaoli888原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。