use*_*470 3 .net c# azure wkhtmltopdf dinktopdf
我写了一个使用dinktopdf的 PDF 生成 API将一些模板化的 HTML 转换为字节数组。这一切在我的本地机器上运行良好,但是当我部署到我的 azure web 应用程序时,API 只能运行一次。当我第二次尝试时,我收到以下消息和 502 错误:
指定的 CGI 应用程序遇到错误,服务器终止了该进程。
这是我的代码的精简版本,仍然出现相同的错误:
static IPdfConverter pdfConverter = new SynchronizedConverter(new PdfTools());
public static byte[] BuildPdf(string html)
{
return pdfConverter.Convert(new HtmlToPdfDocument()
{
Objects =
{
new ObjectSettings
{
HtmlContent = html
}
}
});
}
Run Code Online (Sandbox Code Playgroud)
我还尝试使用IronPDF进行 HTML 到 PDF 的转换,并遇到了同样的问题(在本地机器上完美运行,但在 Azure 部署上只出现一次,然后出现一致的 502 错误)。
如果使用var converter = new SynchronizedConverter(new PdfTools());\xc2\xb4, remove it, and just injectIConverter in your service. \nI tried and this approach is working, after all, we already register the converter, we don't need to create an instance using thenew` 关键字初始化转换器。我的应用程序不在 Azure 上,但我有同样的问题,转换器在第一次调用后挂起,因此我决定写下此评论。
| 归档时间: |
|
| 查看次数: |
1863 次 |
| 最近记录: |