HTML to PDF Convertion Azure Functions v3

Hello,

I want to convert HTML strings to PDF within an Azure Function V3 and getting following errors:

Syncfusion.Pdf.PdfException: Html conversion failed
   at Syncfusion.HtmlConverter.HtmlConverter.CheckConversionDone(String tempFilePath)
   at Syncfusion.HtmlConverter.HtmlConverter.ConvertHtmlToPdf(String url, Int32 width, Int32 height, String tempFile)
   at Syncfusion.HtmlConverter.HtmlToPdfConverter.Convert(String url)

On my machine everything is working and im able to create PDF's for my HTML strings, now i wanted to publish the Function to Azure and this error occurs.

I tried following things which i found here: https://www.syncfusion.com/forums/148308/syncfusion-pdf-pdfexception-html-conversion-failed
  • Function Plattform settings to 64 Bit.
  • Update my AppService Plan to B1 instead of consumption.
  • Remove/uncheck the "Run from package file" Setting while deploying.
Nothing is working, the exception stays.

I found this tutorial within the forums entry: https://www.syncfusion.com/kb/10301/how-to-convert-html-to-pdf-in-azure-functions-2-0
Copied the code into a new Azure Function V3 Starter Package with updated Nugets and also getting the same exception ("Html conversion failed").

Then I downloaded the project from the tutorial (HTMLToPDFV20225383934) and just published it in the same way as its written in the tutorial.
Finally it works :)

My problem now, the AzureFunctionVersion V2 is deprecated. 
So i tried to update the Nuget Packages from the HTMLToPDFV20225383934 Project, published it (also with the AzureFunctionVersion 2) and it throws again the "Html conversion failed" exception.

So my question is, is it possible to convert HTML's to PDF's inside Azure Functions V3?
I think the solution with the deprecated V2 Function isnt useful. 
Or did i just missed something in the tutorial/torum entries where this is explained?

Please help me, i hope my steps are enough to reproduce this problem.
If you need any further informations please let me know.

Thanks,

BR.


12 Replies 1 reply marked as answer

GK Gowthamraj Kumar Syncfusion Team December 14, 2020 12:50 PM UTC

Hi BR, 
 
Thank you for contacting Syncfusion support.  
 
We have checked the HTML to PDF conversion with WebKit in Azure functions V3 and the conversion is working without any exception. We have attached the sample which we ensured in our side. Please try the below sample and let us know the result. 
 
 
Note: Kindly copy the QtBinariesWindows folder to the Azure function project directory.  
 
If still you are facing the same exception, kindly share us the azure environment details such as hosting plan, region, country etc., of the server, it will be helpful for us to analyse and assist you further on this.  

Regards, 
Gowthamraj K   



GW Gerhild Wachauer replied to Gowthamraj Kumar December 14, 2020 04:13 PM UTC

Hi BR, 
 
Thank you for contacting Syncfusion support.  
 
We have checked the HTML to PDF conversion with WebKit in Azure functions V3 and the conversion is working without any exception. We have attached the sample which we ensured in our side. Please try the below sample and let us know the result. 
 
 
Note: Kindly copy the QtBinariesWindows folder to the Azure function project directory.  
 
If still you are facing the same exception, kindly share us the azure environment details such as hosting plan, region, country etc., of the server, it will be helpful for us to analyse and assist you further on this.  

Regards, 
Gowthamraj K   


Hi Gowthamraj K, thanks for your reply!

I tried your solution, it works again locally but if im publish the project, im getting the same error as mentioned in my forum post.





I tested it with following steps.

Download Project, get QtBinariesWindows from:



Added the whole folder to the function project (add all files with "CopyToOuputDirectory" to "Copy If newer" as you can see on the screenshot. And changed some small details in the function Project:


I Published the Function inside a B1 App Service Plan and Windows Hosting Environment.
The Run from Package file is not checked.





Im not quite sure what im doing wrong. Can you help me? How I need to publish this solution?

Best Regards, 

Michael


GK Gowthamraj Kumar Syncfusion Team December 15, 2020 02:29 PM UTC

Hi Michael, 

Thank you for sharing the details.   
  
We have checked the provided details on our end, all are provided properly. We suspect that the issue may occur due to that HTML file that you are used in your conversion. Kindly please share the details such as complete input HTML file/URL (with all resources styles, scripts, etc.,) or modified sample to reproduce the issue on our end. So, that it will be helpful for us to analyze and assist you further on this.    
  
However, kindly please try the simple URL to PDF conversion (https://www.google.com/ ) on your end and let us know the result.   

Regards, 
Gowthamraj K 



GW Gerhild Wachauer December 15, 2020 03:26 PM UTC

Hi Gowthamraj K,

I tried it again with the url conversion (included in the Attached Project also) and it did not work.
I attached the project which i take for test. (your included project with the steps which i described in my earlier answer).
I just added the QtBinariesWindows to the solution and activated the logger + set the AutorizationLevel of the function to trigger it directly from my browser, but yes check it please in my zipped solution.
All steps are documented in my answer from earlier.

Locally, everything is working fine, since i publish the solution, the exception comes again.

Thanks,

BR, Michael





Attachment: AzureFunction_V3_HtmlToPdf_WebKit1921012595_e9768ef9.zip


PV Prakash Viswanathan Syncfusion Team December 16, 2020 03:56 PM UTC

Hi Michael, 
 
Thank you for the details.  
 
Currently we are working on this issue and we will update you with further details by Dec 18, 2020. 
 
Regards, 
Prakash V  



GK Gowthamraj Kumar Syncfusion Team December 18, 2020 03:24 PM UTC


Hi Michael, 

We were able to reproduce the reported issue in our end. Currently, we are validating on this and update the further details on December 22nd 2020. 

Regards, 
Gowthamraj K 



GK Gowthamraj Kumar Syncfusion Team December 22, 2020 05:33 PM UTC

Hi Michael, 

Thank you for your patience. 

We have further analysed about the reported issue, it is occurring due to QtBinariesWindows folder is not copied properly to the output directory. So, the reported HTML Conversion failed exception occurs.  
 
We can resolve this issue by copying all the files in the QtBinariesWindows and set the proper path. Please ensure all the files and inner folder are properly copied in Azure server using console in Azure portal. If it is not copied, kindly add all the files manually to resolve that issue. This is not an issue in our library.   
 
Please refer below screenshots for the file copy issue, it is not copying all the files in a QtBinariesWindows folder and inner folders.  
 
 
 
 
 
If still you are facing the same issue, we can have web meeting to directly look into the issue in your machine and provide you the solution at the earliest. Please let us know your availability for web meeting.  

Regards, 
Gowthamraj K 



GW Gerhild Wachauer January 12, 2021 09:00 AM UTC

Hi Gowthamraj K,

I checked also the files which gets published to azure and I think there is everything included (in the bin directory). 



In the wwwroot directory, there is also a QtBinariesWindows Folder, which holds less files: 


For the WebKitPath I use following parsing, I think this should be inside the bin directory (at least while debugging)


Im not quite sure what a web call should help, but yes its possible. 
I think it would be easier if you download my solution which I posted earlier (Attachment:  AzureFunction_V3_HtmlToPdf_WebKit1921012595_e9768ef9.zip from date: December 15, 2020 03:26 PM UTC), and upload it to an azure function v3 + document all steps so I can try to reproduce it (maybe post also the url from the azure function endpoint so I can check it the whole way). 
I already give you all informations + source code from my side, the environment is an Azure Function v3 App running on Windows (all details are in my Post or answers).

Can you please give me a working example? Or give me advice in relation to my solution which I uploaded? Is there anything wrong? What is wrong? 

BR. 
Michael




GK Gowthamraj Kumar Syncfusion Team January 13, 2021 05:26 PM UTC

Hi Michael, 
 
We have created a new incident under your Direct Trac account. We suggest you follow up with the incident for further updates. Please log in using the below link.  

Regards, 
Gowthamraj K 



VJ Vincent James Paz June 1, 2021 02:40 PM UTC

Any resolution to can provide? I am having the same problem. my App Service Plan is B1, all QT files are included in the wwwroot. my App Platform is currently set to 64Bit.


VJ Vincent James Paz replied to Vincent James Paz June 1, 2021 02:59 PM UTC

Any resolution to can provide? I am having the same problem. my App Service Plan is B1, all QT files are included in the wwwroot. my App Platform is currently set to 64Bit.

Update: I was able to fix my issue after changing the deployment method to "ZIP Deploy". saw it from another thread. Thank you!

Marked as answer

GK Gowthamraj Kumar Syncfusion Team June 2, 2021 10:57 AM UTC

Hi Vincent, 
 
Thank you for your update. We are glad to know that your problem has been solved. 
 
Regards, 
Gowthamraj K 


Loader.
Up arrow icon