我创建了一个通过adobe reader打印pdf的功能。一切正常,但我无法抑制打印对话框。我想要的是直接通过打印机打印文件,而不会弹出打印对话框。
这是打印功能,但每次调用时都会弹出打印对话框。我正在进行批量pdf打印,所以我不想每次都弹出。
public static bool PrintPDFs(string pdfFileName)
{
try
{
var proc = new Process
{
StartInfo =
{
WindowStyle = ProcessWindowStyle.Hidden,
Verb = "print",
FileName =
Registry.LocalMachine.OpenSubKey("Software")
.OpenSubKey("Microsoft")
.OpenSubKey("Windows")
.OpenSubKey("CurrentVersion")
.OpenSubKey("App Paths")
.OpenSubKey("AcroRd32.exe")
.GetValue(string.Empty)
.ToString(),
//Define location of adobe reader/command line
//switches to launch adobe in "print" mode
Arguments = string.Format(@"/p /h {0}", pdfFileName),
UseShellExecute = false,
CreateNoWindow = true
}
};
proc.Start();
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
if (!proc.HasExited)
{
proc.WaitForExit(10000);
}
proc.EnableRaisingEvents = true;
proc.Close();
KillAdobe("AcroRd32");
return true;
}
catch
{
return false;
}
}