nachdem ich tagelang nach einer Lösung gesucht habe, um PDFs "silently" aus meiner C# Konsolenanwendung heraus zu drucken, hier mein Code, um anderen die Recherchezeit zu ersparen. Ich greife auf den Adobe Reader zu:
PrintDialog pDialog = new PrintDialog();
if (pDialog.ShowDialog() == DialogResult.OK)
{
DirectoryInfo unzippedFolder = new DirectoryInfo(zibname);
foreach (FileInfo file in unzippedFolder.GetFiles())//print each PDF-file within the unzipped folder
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = @"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe";
Process process = new Process();
startInfo.Arguments = String.Format("/h /t \"{0}\" \"{1}\"", file.FullName, pDialog.PrinterSettings.PrinterName);//file.FullName: full path of PDF file startInfo.CreateNoWindow = true;
startInfo.ErrorDialog = false;
startInfo.UseShellExecute = false;
process = Process.Start(startInfo);
if (!process.WaitForExit(7000))
{
// kill Adobe Reader
process.Kill();
}
}
Lila