public static void HtmlToPdf(string urlPath, string fileName) { string path = AppDomain.CurrentDomain.BaseDirectory; string savepath = fileName; string url = urlPath; try { if (!string.IsNullOrEmpty(url) || !string.IsNullOrEmpty(savepath)) { Log("PDFHelper_path_null_NEW:" + HttpContext.Current.Request.PhysicalApplicationPath + "wkhtmltopdf.exe"); var p = new Process(); string dllstr = HttpContext.Current.Server.MapPath("~/wkhtmltopdf.exe"); // path + "wkhtmltopdf.exe"; if (System.IO.File.Exists(dllstr)) { p.StartInfo.FileName = dllstr; p.StartInfo.Arguments = " \"" + url + "\" \"" + savepath + "\""; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.CreateNoWindow = true; p.Start(); p.WaitForExit(); } } } catch (Exception ex) { Log(ex.Message+ex.StackTrace); throw new Exception(ex.ToString()); } }