求助,使用wkhtmltopdf將aspx頁面轉換為PDF失敗了解決方案
二公子呀 2020-06-11 05:04:26 try
{
ProcessStartInfo processStartInfo = new ProcessStartInfo();
processStartInfo.FileName = sPdfToolPath;
processStartInfo.WorkingDirectory = Path.GetDirectoryName(sPdfToolPath);
processStartInfo.UseShellExecute = false;
processStartInfo.CreateNoWindow = true;
processStartInfo.RedirectStandardInput = true;
processStartInfo.RedirectStandardOutput = true;
processStartInfo.RedirectStandardError = true;
processStartInfo.Arguments = sArgument;
Process p = Process.Start(sPdfToolPath);
p.StartInfo = processStartInfo;
p.Start();
p.WaitForExit();
FileStream fs = new FileStream(sSavePath + "\\" + sFileName, FileMode.Open);
byte[] file = new byte[fs.Length];
fs.Read(file, 0, file.Length);
fs.Close();
}
catch (System.Exception ex)
{
return ex.Message;
}
執行至Process p = Process.Start(sPdfToolPath);這裡時未能轉換為PDF直接閃過,實際沒有轉換成功