我使用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.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时才会出现此问题,否则它可以正常工作。
答案 0 :(得分:0)
感谢大家的贡献
最后我破解了它
我在参数中添加了-q,它运行良好