0

I have code that I took from How can I send a file document to the printer and have it print?. When I was running this on my machine, it worked flawlessly. Once I put it on a VM for testing, it is no longer printing. I discovered this is probably due to the application not opening Adobe. I have given access to the folder where the PDFs reside in, and changed the security settings in Adobe.

My code:

try
{
  ProcessStartInfo info = new ProcessStartInfo();
  info.Verb = "print";
  info.FileName = @"properFilePath.pdf";
  info.CreateNoWindow = true;
  info.WindowStyle = ProcessWindowStyle.Normal; // so I know Adobe is opening
  TimeSpan tp = new TimeSpan(0, 0, 10); // I thought this did something different than what it really does
  Process p = new Process();
  p.StartInfo = info;
  p.Start();
  p.WaitForInputIdle();
  System.Threading.Thread.Sleep(tp);
  if (false == p.CloseMainWindow())
  {
     p.Kill();
  }
  Message m = new Message() { Msg = "Worked, yo", MsgType = Message.MessageType.Success };
  Logger.Log(m);
  return true;
}
catch (Exception ex)
{               
    //I log this I swear
    return false;
}

I'm looking to be pointed in the right direction for solutions/help/answers.

Thanks

Community
  • 1
  • 1
Corey Whaley
  • 66
  • 3
  • 11
  • 1
    do you have the same application on the VM that you do on your local, for example `Adobe` can you add any actual error trapping / logging so the you can capture `ex.Message` – MethodMan May 11 '17 at 19:33
  • @MethodMan I was just looking for one a log of `Adobe` on the VM and could not find one. They're the same version, etc. I also confirmed that the process is starking – Corey Whaley May 11 '17 at 20:28
  • When you run your code in the VM, nothing happens at all? – stelioslogothetis May 12 '17 at 15:11
  • @Sty It goes through the process, and logs the info that it hasn't failed. – Corey Whaley May 12 '17 at 16:13

0 Answers0