chr*_*isb 5 azure wkhtmltopdf azure-web-app-service
我使用的是https://github.com/codaxy/wkhtmltopdf包装在我的网站创建网页的PDF(我传递一个绝对URL如http://mywebsite.azurewebsites.net/PageToRender.aspx它在 dev 和另一个共享主机帐户上工作正常,但是当我部署到 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();
}
}
Run Code Online (Sandbox Code Playgroud)
查看有关类似问题的SO问题。这家伙似乎已经开始工作了。RotativaPDF 建立在 wkhtmltopdf 之上,因此有连接。我正在我们的 Azure 网站上亲自尝试 - 我将在不久的将来发布我的结果。
适用于 ASP.NET MVC3 的 Azure 和 Rotativa PDF 打印
| 归档时间: |
|
| 查看次数: |
1754 次 |
| 最近记录: |