The following code will search for all files in a give directory, use a method call PrintPDFs to automatically send the file to the default printer on the machine that this code is run on.
It will use adobe's ability to silently print a PDF, it will still open the files but i've also included code called FindAndKillProcess which will close adobe.
Without spending tons for a more sophisticated component this is going to be...probably at least...one of the easier options you'll have.
If you look at itextsharp or pdfsharp there are options to print the PDF that way which is the way i ended up going but the code below should work.
string[] files = Directory.GetFiles(sourceFolder);
foreach (string file in files)
{
PrintPDFs(file);
}
public static Boolean PrintPDFs(string pdfFileName)
{
try
{
Process proc = new Process();
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.StartInfo.Verb = "print";
proc.StartInfo.FileName = IOUtils.GetApplicationPath(pdfFileName, "pdf");
proc.StartInfo.Arguments = String.Format(@"/p /h {0}", pdfFileName);
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
proc.Start();
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
if (proc.HasExited == false)
{
proc.WaitForExit(10000);
}
proc.EnableRaisingEvents = true;
proc.Close();
FindAndKillProcess("AcroRd32");
return true;
}
catch
{
return false;
}
}
public static bool FindAndKillProcess(string name)
{
foreach (Process clsProcess in Process.GetProcesses())
{
if (clsProcess.ProcessName.StartsWith(name))
{
clsProcess.Kill();
return true;
}
}
return false;
}