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