Hi,
I developed a windows service in c#.net with framework 2.0, last 4 years its printing pdf files fine, but now this printing logic failed to print PDF doc version 9.5, 10, and 11.
Please help to find out solution, why this windows service started failing in printing for higher version of adobe reader documents.
One more intresting thing - this logic is working fine with destop test c#.net application, but not working with windows service.
My code is below -
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics. ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(this.Adobe_File_And_Path);
process.StartInfo = psi;
process.Start();
psi.UseShellExecute = false;
psi.RedirectStandardOutput =true;
psi.RedirectStandardInput = true;
psi.RedirectStandardError = true;
psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
psi.Arguments = "/n /h /p \"" + this.PDF_Name_And_Path + "\"";
for (int i = 1; i <= 20; i++)
//20 loops is about 10 seconds
{
System.Threading.Thread.Sleep(500);
//500 = 1/2 second.
System.Windows.Forms.Application.DoEvents();
//Process any waiting events
if (process.HasExited)
break;
//The loop
}
if (!(process.HasExited))
{
if(!process.CloseMainWindow())
{
//2 second sleep
process.Kill();
//Kill forcefully
}
}
Waiting for your helping hand.
Thanks in advance.
Rakesh
}
}