title: How to print PDF document from Windows Service
body: <p>I have windows service that must periodically print PDF document from server. My function is</p>
  
  <pre><code>private void PrintFormPdfData(byte[] formPdfData)
  {
      string tempFile;
  
      tempFile = Path.GetTempFileName();
  
      using (FileStream fs = new FileStream(tempFile, FileMode.Create))
      {
          fs.Write(formPdfData, 0, formPdfData.Length);
          fs.Flush();
      }
  
      string pdfArguments = string.Format("/p /h\"{0}\"", tempFile);
  
      string pdfPrinterLocation = @"C:\Program Files (x86)\Adobe\Reader 9.0\Reader\AcroRd32.exe";
  
  
      ProcessStartInfo newProcess = new ProcessStartInfo(pdfPrinterLocation, pdfArguments);
      newProcess.CreateNoWindow = true;
      newProcess.RedirectStandardOutput = true;
      newProcess.UseShellExecute = false;
      newProcess.RedirectStandardError = true;
  
      Process pdfProcess = new Process();
      pdfProcess.StartInfo = newProcess;
      pdfProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
      pdfProcess.Start();
      pdfProcess.WaitForExit();
  }
  </code></pre>
  
  <p>When I implement this in Windows Application it works, but when I implement in Windows service it does not work.</p>
  
  <p>Can you help me?</p>