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 (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.
update:
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.
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.
-- update 2017 --
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.
I've successfully managed to get wkhtmltopdf working on Azure functions backed by app service. I've used the OpenHtmltoPdf c# package which installs the wkhtmltopdf library automatically. I've published all the required files here:
https://gist.github.com/tmakin/80e1905094245c857c493b7879657095
Update July 2018
I've now switched to DinkToPdf for pdf on azure functions v2 which runs on net core. See here for more info:
https://odetocode.com/blogs/scott/archive/2018/02/14/pdf-generation-in-azure-functions-v2.aspx
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.
update:
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.
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.
-- update 2017 --
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.
© 2022 - 2024 — McMap. All rights reserved.