Hallo,
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();
}
}
Viele Grüße
Lila
Hallo,
warum hast du nicht s.u. verwendet?
startInfo.Verb = “print”;
Keine Kritik. Nur für mein Verständnis 😉
Beste Grüße
Hi Larkem,
um ehrlich zu sein weiß ich nicht genau, unter welchen Umständen man das print Verb verwenden sollte/muss oder warum ich es in meinem Code nicht benötige. Falls es jemand erklären könnte, das wäre super. 😃
Gruß
Lila