0

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;
        }
    }
  • There are already some threads: http://stackoverflow.com/questions/4868982/c-sharp-printing-a-pdf-silently-with-adobe-acrobat http://stackoverflow.com/questions/5508763/c-sharp-prevent-adobe-reader-window-from-coming-up-when-trying-to-print-a-docume It's not possible – Daniel Abou Chleih Sep 07 '13 at 21:44
  • Is it possible with Foxit Reader? –  Sep 07 '13 at 22:03
  • I just tested your code (I wasn't at home yesterday). Which version of Adobe Reader are you using? I am using v10.1.7.27 and your solution is working fine for me. – Daniel Abou Chleih Sep 08 '13 at 09:24
  • @DanielAbouChleih I am using 11.0.3 and my requirement is also for above 11 only. Is it printing all the pages without any human intervention..!! –  Sep 08 '13 at 11:15
  • Yes it is directly printing your pdf, but does not close adobe. – Daniel Abou Chleih Sep 08 '13 at 11:31
  • With me when I click OK on the dialog, it prints and then closes adobe properly. –  Sep 08 '13 at 12:12

0 Answers0