背景:使用wkhtmltopdf工具將html轉換成pdf時,這個工具在進行轉換時會彈出命令行窗口顯示轉換過程,可是在項目運行時彈出服務器忽然彈出控制檯窗口會很奇怪,尤爲是當轉換多個時。解決這個問題html
修改以前的代碼shell
ProcessStartInfo startInfo = new ProcessStartInfo(wtHtmlToPdfEXEPath, Process process = Process.Start( process.WaitForExit();
修改以後的代碼服務器
ProcessStartInfo startInfo = new ProcessStartInfo(wtHtmlToPdfEXEPath, switches); //設置不在新窗口中啓動新的進程 startInfo.CreateNoWindow = true; //不使用操做系統使用的shell啓動進程 startInfo.UseShellExecute = false; //將輸出信息重定向 startInfo.RedirectStandardOutput = true; Process process = Process.Start( process.WaitForExit();