62,046
社区成员
发帖
与我相关
我的任务
分享
Process process = new Process();
process.StartInfo.FileName = "e:\web\wkhtmltopdf.exe";
process.StartInfo.Arguments = "e:\web\TestPDF.htm e:\web\TestPDF.pdf";
process.Start();
string wkhtmltopdfPath = HttpContext.Current.Server.MapPath(@"wkhtmltopdf\wkhtmltopdf.exe");
if (!File.Exists(wkhtmltopdfPath))
{
throw new Exception(String.Format("File '{0}' not found. Check if wkhtmltopdf application is installed.", wkhtmltopdfPath));
}
ProcessStartInfo si;
StringBuilder paramsBuilder = new StringBuilder();
paramsBuilder.Append("--page-size A4 ");
paramsBuilder.AppendFormat("\"{0}\" \"{1}\"", "-", fileNameWithOutExtention);
si = new ProcessStartInfo();
si.CreateNoWindow = true;
si.FileName = wkhtmltopdfPath;
si.Arguments = paramsBuilder.ToString();
si.UseShellExecute = false;
si.RedirectStandardError = true;
si.RedirectStandardInput = true;