【发布时间】:2013-01-20 01:03:00
【问题描述】:
我正在使用 https://github.com/codaxy/wkhtmltopdf 包装器从我网站上的网页创建一个 pdf(我传入一个绝对 URL,例如 http://mywebsite.azurewebsites.net/PageToRender.aspx 它在开发人员和另一个共享主机帐户中运行良好,但是当我部署到一个 Azure 网站失败了,我得到的只是一个 ThreadAbortException。 是否可以在 azure 上使用 wkhtmltopdf,如果可以,我做错了什么?
更新: 这个仅使用 Process.Start 的简单示例也不起作用。它只是在 Azure 上运行时挂起,但在其他服务器上运行良好。
string exePath = System.Web.HttpContext.Current.Server.MapPath("\\App_Data\\PdfGenerator\\wkhtmltopdf.exe");
string htmlPath = System.Web.HttpContext.Current.Server.MapPath("\\App_Data\\PdfGenerator\\Test.html");
string pdfPath = System.Web.HttpContext.Current.Server.MapPath("\\App_Data\\PdfGenerator\\Test.pdf");
StringBuilder error = new StringBuilder();
using (var process = new Process())
{
using (Stream fs = new FileStream(pdfPath, FileMode.Create))
{
process.StartInfo.FileName = exePath;
process.StartInfo.Arguments = string.Format("{0} -", htmlPath);
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.UseShellExecute = false;
process.Start();
while (!process.HasExited)
{
process.StandardOutput.BaseStream.CopyTo(fs);
}
process.WaitForExit();
}
}
【问题讨论】:
-
我们在 Windows 2012 Server 上运行的托管环境中运行 wkhtmltopdf 时遇到问题。如果有帮助,您可以阅读该页面在此pastebin 处吐出的错误
-
你找到解决办法了吗?
-
没有。看来您无法在 azure 网站上执行此操作。我们使用了在另一台主机上运行 wpf 服务的解决方法。
标签: azure wkhtmltopdf azure-web-app-service