且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

这是什么原因EvoPDF"无法呈现HTML"当部署到Azure的网站除外

更新时间:2022-10-23 14:58:38

您已经打了Azure的应用程序服务的沙箱运行exectution限制。

从的https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#unsupported-frameworks:


  

不支持框架


  
  

下面是已发现要无法使用由于一个或多个上述限制框架和场景的列表。这是可以想象的,有些人会在未来随着沙箱的发展予以支持。


  
  

PDF生成器发生故障,由于限制上面提到的:


  
  

EVOPDF 结果
  Rotativa结果
  wkhtmltopdf结果
  Syncfusion结果
  Siberix结果
  NReco(使用wkhtmltopdf)结果
  Spire.PDF结果


  
  

其他方案:结果
  PhantomJS /硒:试图连接到本地地址,并且还使用GDI +


块引用>

当你已经提到这工作正常在Web /辅助角色(云服务)。
服务织物或IaaS的VM其他的选择。

Using EvoPDF for a .Net web application works locally, however once deployed to a Microsoft Azure website it throws a generic exception: "unable to render html".

Stack trace:

[Exception: Could not render the HTML string.]
   EvoPdf.HtmlToImageConverter.ᜀ(String A_0, String A_1, String A_2, ᜴& A_3, Hashtable& A_4) +2129
   EvoPdf.HtmlToPdfConverter.ᜀ(String A_0, String A_1, String A_2, String A_3, Boolean A_4) +8369
   EvoPdf.HtmlToPdfConverter.ᜀ(Stream A_0, String A_1, String A_2, String A_3, String A_4, Boolean A_5) +58
   EvoPdf.HtmlToPdfConverter.ᜁ(String A_0, String A_1, String A_2, String A_3, Boolean A_4) +126
   EvoPdf.HtmlToPdfConverter.ConvertHtml(String htmlString, String baseUrl, String internalLinksBaseUrl) +33
   EvoPdf.HtmlToPdfConverter.ConvertHtml(String htmlString, String baseUrl) +12
   td.Printing.Labels.Print.WithEvoPdf(HttpContext httpContext, Action`1 htmlPageRenderer, String outputFileName, Label labelFormat) in C:\...\Evo PDF Print Labels.vb:54
   td.OL3016WR.Render(HtmlTextWriter writer) in C:\...\OL3016WR.aspx.vb:166
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +80
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +8921

You've hit an Azure App Service sandbox runtime exectution limitation.

From https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#unsupported-frameworks:

Unsupported frameworks

Here is a list of frameworks and scenarios that have been found to be not be usable due to one or more of the restrictions above. It's conceivable that some will be supported in the future as the sandbox evolves.

PDF generators failing due to restriction mentioned above:

EVOPDF
Rotativa
wkhtmltopdf
Syncfusion
Siberix
NReco (uses wkhtmltopdf)
Spire.PDF

Other scenarios:
PhantomJS/Selenium: tries to connect to local address, and also uses GDI+.

As you already mentioned this works fine in a Web/Worker Role (Cloud Services). Service Fabric or IaaS VM are other options.