仅当我们在C#net中将打印机设置为默认打印机时才打印PDF
以下代码用于打印PDF仅当我们在C#net中将打印机设置为默认打印机时才打印PDF,c#,C#,以下代码用于打印PDF private void PrintReport(string printerName,string filePath) { ProcessStartInfo info = new ProcessStartInfo(); info.Verb = "print"; info.FileName = filePath; info.CreateNoWindow = t
private void PrintReport(string printerName,string filePath)
{
ProcessStartInfo info = new ProcessStartInfo();
info.Verb = "print";
info.FileName = filePath;
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
info.Arguments = printerName;
Process p = new Process();
p.StartInfo = info;
p.StartInfo.Arguments = String.Format(@"/p {0}/h {1}", printerName, filePath);
p.Start();
p.WaitForInputIdle();
System.Threading.Thread.Sleep(3000);
if (false == p.CloseMainWindow())
p.Kill();
if (File.Exists(filePath))
{
File.Delete(filePath);
}
}
但仅当指定的打印机是默认打印机时,它才起作用。
需要使用指定的打印机(printerName)进行打印。有人能告诉我会出现什么问题吗