Azure websites and wkhtmltopdf

主宰稳场 提交于 2019-12-18 12:18:33

问题


So after beginning my azure websites-adventure, I have been encountering disappointment after disappointment to the point of 'almost' regretting taking the azure route..the latest: my app uses wkhtmltopdf(Rotativa) for all its PDF generation. And as I discovered now during my staging testing...that doesnt work. According to most info on the web, azure websites cannot run .exe's. However, most info I've seen is by now 2 years old and I know Azure development is going fast.

Is there by now a way to run wkhtmltopdf on azure websites, or a workaround atleast? I cannot really find a free alternative like wkhtmltopdf to seems to be working.(Itextsharp doesnt seem to like my html, so thats no option).


回答1:


Running wkhtmltopdf is 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 in Azure Web Apps.

Hosting - App Service Plan

There are numerous wrappers available (TuesPechkin, Codaxy, etc.). Codaxy is an EXE wrapper in .NET while TuesPechkin is a .NET wrapper around C++ runtime using P/Invoke over wkhtmltox.dll.




回答2:


Running wkhtmltopdf in Azure Websites in a simple way seems to be impossible, still. Static .NET wrappers like Pechkin wont work either in WebSites, there are very few alternatives that are 1. free and 2. dont use wkhtmltopdf or similar under the hood. Most alternatives like iTestSharp are not very advanced when it comes to html/css3/javascript reading (as I do some design changing with .js on page load).

I ended up creating a Azure Cloud Service, that runs wkhtmltopdf.exe without any issues. I send the html to the service, and get a byte[] in return. So far this seems to be working fine. Hope this helps others with similar problems.



来源:https://stackoverflow.com/questions/28682110/azure-websites-and-wkhtmltopdf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!