Wht是将HTML转换为PDF的最佳解决方案(在Azure Web应用程序上)

问题描述:

实际上,我正在尝试使用NReco PDF转换器将html内容转换为pdf,但是,这行代码pdfDoc.GeneratePdf(HtmlContent); 无法通过Azure Web应用进行访问,但在我的开发环境中正常运行.所以我的问题是我应该选择哪种云服务?

Actually I am trying to convert html content to pdf using NReco PDF converter, however, this line of code pdfDoc.GeneratePdf(HtmlContent); unable to get through on Azure web app, but it works normally on my dev environment. So my Question is which cloud service should i go for?

Azure Apps(以前的WebSites)在受限(部分信任)环境中运行,并且wkhtmltopdf.exe(NReco PdfGenerator包装器内部使用)无法在以下环境中执行这种情况直接来自asp.net应用程序.

Azure Apps (former WebSites) operate in restricted (partial-trust) environment and wkhtmltopdf.exe (that is internally used by NReco PdfGenerator wrapper) cannot be executed in this case directly from asp.net application.

更新:

不幸的是,它也不适用于Azure WebJob:在与WebSite相同的(受限)环境下执行任务,并且禁用了wkhtmltopdf使用的GDI功能.

Unfortunately it will not work with Azure WebJobs as well: tasks are executed under the same (limited) environment as WebSites and GDI functions used by wkhtmltopdf are disabled.

如果您的ASP.NET应用程序使用基于wkhtmltopdf的组件生成PDF(无论调用方式如何-在单独的过程中还是作为本机DLL API),它将仅在Azure WebRole/WorkerRole/VM下工作.

If your ASP.NET app uses wkhtmltopdf-based component for PDF generation (doesn't matter how it is invoked - in separate process or as native DLL API) it will work only under Azure WebRole / WorkerRole / VM.

-更新2017年-

Wkhtmltopdf(和NReco PdfGenerator包装器)可以与基于VM的订阅计划(基本或更高版本)的Azure Apps一起使用.至少仍然存在一个问题:似乎字体API仍然受到限制,并且自定义字体无法呈现为PDF.

Wkhtmltopdf (and NReco PdfGenerator wrapper) can be used with Azure Apps with VM-based subscription plan (Basic or higher). At least one issue still exists: it seems fonts API is still restricted and custom fonts cannot be rendered to PDF.