2
我試圖從我的Windows服務打印一個PDF文件。它沒有工作。後來我寫了一個控制檯應用程序來打印一個PDF文件。控制檯應用程序沒有工作!。Afterwords ii called that console從服務的應用程序打印PDF文件它didn'work。爲什麼「打印」不適用於Windows服務?以下是我試過的代碼片段如何使用Windows服務打印PDF文件
1.Used adobe reader:
PdfReportGeneration.Log logs = new PdfReportGeneration.Log();
logs.writeLog("PrintDocument filepath:-" + filepath);
Process process = new Process();
process.StartInfo.FileName = filepath;
process.StartInfo.UseShellExecute = true;
process.StartInfo.Verb = "printTo";
process.StartInfo.Arguments = "HP LaserJet P1005";
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.Start();
process.WaitForInputIdle();
process.Kill();
2. Used foxit reader/adobe reader both didnt work
string sArgs = " /t \"" + filepath + "\" \"" + "HP LaserJet P1005" + "\"";
System.Diagnostics.ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = @"C:\Program Files\Foxit Software\Foxit Reader\Foxit Reader.exe";
startInfo.Verb = "printTo";
startInfo.Arguments = sArgs;
startInfo.CreateNoWindow = true;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
System.Diagnostics.Process proc = Process.Start(startInfo);
proc.WaitForExit(100000); // Wait a maximum of 10 sec for the process to finish
if (!proc.HasExited)
{
proc.Kill();
proc.Dispose();
// return false;
}*/
做了很多google bing yahoo ..沒用!!
serviceProcessInstaller在這裏是什麼? – flute
並沒有它沒有工作:-(嘗試作爲管理員! – flute
作爲下一步,我會嘗試讓該進程有自己的窗口。也許你可以在那裏找到發生了什麼在這個過程中 –