Azure 网站和 wkhtmltopdf

Azure websites and wkhtmltopdf

所以在开始我的 azure websites-adventure 之后,我遇到了一次又一次的失望,以至于 'almost' 后悔走 azure 路线..最新:我的应用程序使用 wkhtmltopdf (Rotativa) 的所有 PDF 生成。正如我现在在分期测试期间发现的那样……那是行不通的。根据网络上的大多数信息,Azure 网站不能 运行 .exe。但是,我看到的大多数信息现在已有 2 年历史,而且我知道 Azure 的开发进展很快。

现在有没有办法在 Azure 网站上 运行wkhtmltopdf,或者至少有解决方法?我真的找不到像 wkhtmltopdf 这样似乎有效的免费替代品。(Itextsharp 似乎不喜欢我的 html,所以那是别无选择)。

运行 wkhtmltopdf 在 Azure 网站中以一种简单的方式似乎仍然是不可能的。 像 Pechkin 这样的静态 .NET 包装器不会在网站中工作,很少有替代品是 1. 免费和 2. 不要使用 wkhtmltopdf 或类似的东西。在 html/css3/javascript 阅读方面,像 iTestSharp 这样的大多数替代方案都不是很先进(因为我在页面加载时使用 .js 进行了一些设计更改)。

我最终创建了一个 Azure 云服务, 运行 wkhtmltopdf.exe 没有任何问题。我将 html 发送到服务,并在 return 中得到一个 byte[]。到目前为止,这似乎工作正常。 希望这能帮助其他有类似问题的人。

运行 wkhtmltopdf 在 Azure Web 应用程序中是 now supported in Azure Web Apps - just make sure you are using Basic, Standard, or Premium App Service Plan. Consumption Service Plan and Free App Service Plan have a more limited sandbox and are NOT supported in my testing. MS confirms supportability of wkhtmltopdf

托管 - 应用服务计划

有许多可用的包装器(TuesPechkin, Codaxy,等等)。 Codaxy 是 .NET 中的 EXE 包装器,而 TuesPechkin 是 C++ 运行时的 .NET 包装器,使用 P/Invoke 而不是 wkhtmltox.dll