我试图从我的 Windows 服务打印一个 pdf 文件。它没有工作。后来我写了一个控制台应用程序来打印一个 pdf 文件。控制台应用程序确实工作了!。Afterwords ii 从服务中调用该控制台应用程序来打印 pdf 文件它没有工作. 为什么“打印”不适用于 Windows 服务?以下是我尝试过的代码片段
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 ..没用!!