C# 程序退出后创建的pdf
我使用wkhtmltopdf在控制台应用程序c#net中创建pdf 下面是代码和代码C# 程序退出后创建的pdf,c#,wkhtmltopdf,C#,Wkhtmltopdf,我使用wkhtmltopdf在控制台应用程序c#net中创建pdf 下面是代码和代码 psi.UseShellExecute = false; psi.FileName = "C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe"; psi.CreateNoWindow = true; psi.RedirectStandardInput = true; psi.RedirectStandardOutput = true; psi.Redirec
psi.UseShellExecute = false;
psi.FileName = "C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe";
psi.CreateNoWindow = true;
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
psi.Arguments = "--enable-javascript --no-stop-slow-scripts --javascript-delay 10000 --page-size A4 --dpi 300 --margin-top 20mm --header-html D:\\header.html --margin-bottom 10mm - --footer-html D:\\footer.html " + tempPath + "\\" + outFileName;
p = Process.Start(psi);
try
{
stdin = p.StandardInput;
stdin.AutoFlush = true;
stdin.Write(HTML);
stdin.Close();
p.WaitForExit(60000);
}
finally
{
p.Close();
p.Dispose();
}
我希望wkhtmltopdf.exe在waitforexit行退出
但我仍然可以在内存中看到它,pdf是用0kb创建的
如果我关闭控制台应用程序,pdf将正确创建
只有在参数中使用页眉和页脚html时才会出现此问题,否则效果很好。感谢大家的贡献 我终于破解了它
我在参数中添加了-q,它运行得很好我已经有一段时间没有使用wkhtmltopdf了,但是页眉和页脚的文件路径需要在引号中吗?(对于不熟悉wkhtmltopdf的其他用户,这些只是命令行参数)不。它在我的控制台应用程序关闭后很好地生成pdf。我没有使用wkhtmltopdf的经验,但请查看可能的问题描述。至于可能的解决方案,我只是检查了我的旧代码,它确实用引号围绕着页眉/页脚的文件路径(我的想法是,它一直在试图破译名称)。我尝试使用引号,没有什么区别,它也是在关闭控制台窗口后创建的