We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Syncfusion.Pdf.PdfException: Html conversion failed

I'm using the webkit renderer/HTML converter to export my HTML and SVG diagram nodes to an image (details in this forum thread). 

On my local development machine, the solution works fine, whether packaged as asp.net core app (.net core 2.2, windows host) or as an azure functions app (.net core 2.2, windows host). 

However when deployed to azure, I encounter the following error: 

Syncfusion.Pdf.PdfException: Html conversion failed
   at Syncfusion.HtmlConverter.HtmlConverter.CheckConversionDone(String tempFilePath)
   at Syncfusion.HtmlConverter.HtmlConverter.ConvertToImage(String url)
   at Syncfusion.HtmlConverter.HtmlToPdfConverter.ConvertToImage(String url)
   at Syncfusion.HtmlConverter.HtmlToPdfConverter.ConvertToImage(String html, String baseurl)


I have checked that all the relevant dependencies (msvcp100.dll and msvcr100.dll) are actually installed on the host server (I checked via the portal console). 

Any clues why this error is occurring?

PS: I have also checked the following pages for clues, but nothing seemed to resolve the error on Azure.
https://www.syncfusion.com/kb/8208/failed-to-convert-the-webpage-exception-with-webkit-html-converter

16 Replies

MI Mithun October 15, 2019 04:50 AM

Ok, I figured out the solution. On Azure you'll have to ensure that the web app (or function app) runs in 64 bit mode (please see screenshot below). 





GK Gowthamraj Kumar Syncfusion Team October 16, 2019 02:33 AM

Hi Mithun, 
 
Thank you for your update. We are glad to know that your reported issue has been resolved.  
 
Regards, 
Gowthamraj K 



AN Andy October 31, 2019 02:50 AM

I'm evaluating syncfusion html to pdf conversion running as a azure function app. I deployed the project from https://www.syncfusion.com/kb/10301/how-to-convert-html-to-pdf-in-azure-functions-2-0 to see if it works, but the azure function throws the exception "Syncfusion.Pdf.PdfException: Html conversion failed".

I tried changing the platform settings to 64 bit, but the exception is still getting thrown. I also tried several plans. It fails with Basic, Standard and ElasticPremium app service plans.

Can you verify if this sample project still runs as an azure function app? And what settings are needed in azure?

Thanks


GK Gowthamraj Kumar Syncfusion Team October 31, 2019 05:42 AM

Hi Andy, 

We have checked the HTML to PDF conversion in Azure Function app and it is working properly. We suspect that the reported exception may occurs when enabling run from package file option when creating a publish target. Please refer below screenshot, 

 

We tried without enabling run from package file option and it is working properly (refer below screenshot). When we publish the azure function with run from package option, the function only has read only permission. But for converting HTML to PDF, we internally launch the browser process from QtBinariesWindows folder. Due to the read only permission, the converter unable to launch the browser process. So, the HTML conversion getting failed. Can you please try the conversion by publishing without run from package option and let us know the result.   

 

Regards, 
Gowthamraj K 



AN Andy November 4, 2019 05:52 AM

I disabled the option "run from package" and the function works now! So there is no need to change the platform settings.

Thanks


GK Gowthamraj Kumar Syncfusion Team November 5, 2019 01:40 AM

Hi Andy, 

Thank you for your update. We are glad to know that your reported exception has been resolved. 
 
Regards, 
Gowthamraj K 



MI Mithun December 19, 2019 11:03 AM

Can anyone confirm whether the solution will work in an consumption plan of azure functions (windows)? 

I've been trying to get it to work, but function times out while calling HtmlToPdfConverter.ConvertToImage()

I see from Gowthamraj's comments in this article's thread that consumption plan is not supported for this solution. Just wanted to check whether anything has changed since then.

Thanks,
Mithun


PV Prakash Viswanathan Syncfusion Team December 20, 2019 12:20 AM

Hi Mithun, 

No, due to the limitations on Azure consumption plan, the HTML converter will not work with consumption plan on Azure function. Kindly try the conversion with basic (B1) or higher plans for converting HTML to PDF/Image on Azure function.  

Please let us know if you need any further assistance on this.  

Regards, 
Prakash V 



MI Mithun December 20, 2019 12:51 AM

Thanks Prakash for confirming. 

One final question. I'd like to host the html -> pdf converter on azure app service for linux

Are there any code-samples or syncfusion knowledgebase article for this? I have seen the samples for app service for windows, but am trying to get this working on app service for linux

Thanks,

-Mithun




PV Prakash Viswanathan Syncfusion Team December 20, 2019 01:02 AM

Hi Mithun, 

Yes, you can host the HTML to PDF converter in Azure app service Linux. Please refer below KB link for more information, 

Please let us know if you need any further assistance on this.  

Regards, 
Prakash V 



MI Mithun December 20, 2019 10:18 AM

Thanks! That worked! 

Thanks,
-Mithun


PV Prakash Viswanathan Syncfusion Team December 23, 2019 12:39 AM

Hi Mithun, 

Thank you for the update.  
Please let us know if you need any further assistance on this.  

Regards, 
Prakash V 



GO Gordon May 6, 2021 12:02 AM

If you're using Azure DevOps to build/deploy, set the deployment method to: 'zipDeploy'.




GK Gowthamraj Kumar Syncfusion Team May 6, 2021 07:21 AM

Hi Gordon,

 
Thank you for your update.   
 
Regards, 
Gowthamraj K 



JP jay patadia August 6, 2021 07:12 AM

I have Azure Function 2.0 runtime dot net core 3.1. I facing the Html conversion error. I have also unchecked the run from the package file option. When I ran in the local machine it works fine. 


Does anyone have any other suggestions for this issue?  


I followed this article https://www.syncfusion.com/kb/10301/how-to-convert-html-to-pdf-in-azure-functions-2-0


Thank you,

Sagar Thakkar



GK Gowthamraj Kumar Syncfusion Team August 9, 2021 07:43 AM

Hi Sagar/Jay, 
 
Thank you for contacting Syncfusion support.

 
We already faced the similar issue in Azure functions 3.1. The reported issue may occurs due to QtBinaries assemblies are not copied properly with Azure SDK 3.0.11. Please follow the below steps to copy the files properly to resolve the reported issue.   
  1. Open the Azure portal in browser.
  2. Navigate to the deployed Azure function in Azure portal.
  3. Open the console of Azure function.
   
  
  1. As we said earlier, QtBinaries assemblies are not copied properly while publish to Azure functions.
  2. So, we need to manually copy all the assemblies from azure portal.
  3. QtBinariesWindows from location “c:\home\site\wwwroot\QtBinariesWindows” does not have all the assemblies, so we need to copy all the assemblies and inner folder from bin folder.
  1. Using cd command, navigate to the location “c:\home\site\wwwroot\bin\QtBinariesWindows” and run the below command.
cp *.* c:\home\site\wwwroot\QtBinariesWindows\  
  
   
  
  1. Then we need to copy the files from “platform” and “imageformats” folders using the same approach.
  1. Using cd command, navigate to the location “c:\home\site\wwwroot\bin\QtBinariesWindows\platforms” and run the below command.
cp *.* c:\home\site\wwwroot\QtBinariesWindows\platforms  
  
  1. Using cd command, navigate to the location “c:\home\site\wwwroot\bin\QtBinariesWindows\imageformats” and run the below command.
cp *.* c:\home\site\wwwroot\QtBinariesWindows\imageformats  
  
  1. Ensure the all the files are copied to “c:\home\site\wwwroot\QtBinariesWindows” location using dir command. Also, ensure the inner folders (imageformats, platforms) has all the files.
   
  1. Now try the conversion from Azure function URL.
  2. We need to copy this assemblies for the first time only.
Regards, 
Gowthamraj K 


Loader.
Live Chat Icon For mobile
Up arrow icon