I have created a function for printing pdf's through adobe reader. It all works fine but I am unable to suppress the print dialog box. What I want is to print the file directly through the printer without the print dialog box popping up.
This is the function for printing but the print dialog pops up everytime it is called. I am doing a batch pdf printing so I don't want it pop every time.
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;
}
}