PdfException: Failed to convert webpage

I am working on a web app (.NET Framework 4.6.2) and have implemented Syncfusion to convert HTML to a PDF (Syncfusion.HtmlToPdfConvert.Blink.AspNet.Mvc5 v 19.1.0.63 and Syncfusion.Pdf.AspNet.Mvc5 v 19.1.0.67. I have the BlinkBinaries included in the root of my project. 

When running the project on my local machine everything works as expected. However, when the web app is deployed to an Azure App Service I receive the following error: 

Message: PdfException: Failed to convert webpage [Returned while handling GET Request]

Stack trace:

Syncfusion.HtmlConverter.BlinkConverter.Convert(String url):303
Syncfusion.HtmlConverter.BlinkConverter.Convert(String htmlString, String baseurl):492
Syncfusion.HtmlConverter.HtmlToPdfConverter.Convert(String htmlString, String baseUrl):1255
OBXCart.Controllers.MachineController.GetCostOfOwnershipPdf(String dateRange, String machineIds) in
      C:\AzureDevOps\toptenusa-1\_work\1\s\OBXCart\Controllers\MachineController.cs:119
(unknown).lambda_method(Closure , ControllerBase , Object[] ):-1
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters):0
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters):83
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters):0
System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c.b__9_0(IAsyncResult asyncResult, ActionInvocation innerInvokeState):0
System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult):0
System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1.End():41
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult):0
System.Web.Mvc.Async.AsyncControllerActionInvoker+AsyncInvocationWithFilters+<>c__DisplayClass11_0.b__0():29
System.Web.Mvc.Async.AsyncControllerActionInvoker+AsyncInvocationWithFilters+<>c__DisplayClass11_2.b__2():134
System.Web.Mvc.Async.AsyncControllerActionInvoker+AsyncInvocationWithFilters+<>c__DisplayClass11_2.b__2():134
System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass7_0.b__1(IAsyncResult asyncResult):0
System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult):0
System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1.End():41
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult):0
System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass3_6.b__4():0
System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass3_1.b__1(IAsyncResult asyncResult):


I have verified the BlinkBinaries are included on the app service server, and for reference here are the general app service settings: 


Any insight would be greatly appreciated! 

Cheers, 
Shane

12 Replies 1 reply marked as answer

GK Gowthamraj Kumar Syncfusion Team June 9, 2021 02:30 PM UTC

Hi Shane, 
 
Thank you for contacting Syncfusion support.  
 
Due to the GDI limitations and restriction of Azure App service environment, the Blink rendering engine does not support conversion in Azure app service (Azure websites) and Azure function. Azure app service environment does not have elevated permissions and enough rights to launch the browser for converting HTML to PDF. However, we can use Blink rendering engine in Azure cloud service, it has elevated permissions and enough rights to launch the browser.  
 
Please refer the below KB link for HTML to PDF conversion in Azure cloud service using Blink,    
  
We can also use Azure App service with docker for deploying the HTML to PDF conversion with Blink rendering engine. Please refer below link for more information,   
 
Our WebKit rendering engine supports converting in Azure app service, kindly our WebKit rendering engine for the conversion. Please refer below link for more information, 
 
Regards, 
Gowthamraj K 


Marked as answer

SO Shane ONeill June 9, 2021 07:51 PM UTC

Gowthamraj, 

Thanks for the response. I am still running locally but have switched to the Webkit rendering engine. This engine however does not do well maintaining the layout of the view after exporting to a PDF. Any tips dealing with this? 

Thank you, 
Shane


GK Gowthamraj Kumar Syncfusion Team June 10, 2021 03:24 PM UTC

Hi Shane, 
 
Thank you for your update. 
 
We are internally using Qt WebKit rendering engine for converting HTML to PDF. QtWebKit rendering engine preserves the output PDF document like how the input HTML file/URL is displayed on the WebKit based web browsers (safari). The same behavior as replicates in our converter. If the HTML page contain Bootstrap4 and advance styles, those styles are not supported in WebKit rendering engine itself. So, currently it is not possible to preserve the bootstrap4 and advance styles on our converter.  
 
If you want to rendered the bootstrap4 styles and reported issue occurs in QtWebKit itself, we have suggest you try our new Blink based HTML converter to overcome this issue. Blink converter internally make use of chromium executable in headless mode for converting HTML to PDF. Kindly refer below link for more information of our Blink converter.   
 
We can also use Azure App service with docker for deploying the HTML to PDF conversion with Blink rendering engine. Please refer below link for more information,    
   
Kindly provide us the complete HTML/URL (with all the resources styles, scripts, etc.,) and output document to check the issue in our end.  So that it will be helpful for us to analyze and assist you further on this. 
   
Regards, 
Gowthamraj K 



SO Shane ONeill June 10, 2021 08:30 PM UTC

Gowthamraj,
 
I have followed your instruction and replaced the Blink rendering engine with Webkit and I am still receiving the same error. Once again, everything works fine locally but fails once deployed in Azure. Per your previous message, it was my understanding that Webkit would be usable in an Azure App service. Is that correct?  

The QTBinaries are included in the root of my web project and set via settings.WebKitPath = Server.MapPath("~/QtBinaries/"). All contents are set to Copy Always for Copy to Output Directory. 

Thanks, 
Shane

Message: PdfException: Failed to convert the webpage [Returned while handling GET Request]

Stack trace:

Syncfusion.Pdf.HtmlToPdf.HtmlToPdfResult.RenderWebKit(PdfPageBase page, PdfLayoutFormat format):6640
Syncfusion.Pdf.HtmlToPdf.HtmlToPdfResult.Render(PdfPageBase page, PdfLayoutFormat format):45
Syncfusion.HtmlConverter.HtmlToPdfConverter.Convert(String htmlString, String baseUrl):1158
OBXCart.Controllers.MachineController.GetCostOfOwnershipPdf(String dateRange, String machineIds) in
      E:\AzureDevOps\toptenusa-1\_work\2\s\OBXCart\Controllers\MachineController.cs:119
(unknown).lambda_method(Closure , ControllerBase , Object[] ):-1
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters):0
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters):83
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters):0
System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c.b__9_0(IAsyncResult asyncResult, ActionInvocation innerInvokeState):0
System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult):0
System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1.End():41
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult):0
System.Web.Mvc.Async.AsyncControllerActionInvoker+AsyncInvocationWithFilters+<>c__DisplayClass11_0.b__0():29
System.Web.Mvc.Async.AsyncControllerActionInvoker+AsyncInvocationWithFilters+<>c__DisplayClass11_2.b__2():134
System.Web.Mvc.Async.AsyncControllerActionInvoker+AsyncInvocationWithFilters+<>c__DisplayClass11_2.b__2():134
System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass7_0.b__1(IAsyncResult asyncResult):0
System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult):0
System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1.End():41
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult):0
System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass3_6.b__4():0
System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass3_1.b__1(IAsyncResult asyncResult):0

Azure App Service Settings:





PV Prakash Viswanathan Syncfusion Team June 11, 2021 06:43 PM UTC

Hi Shane, 

Thank you for the update.  

Yes, we can use WebKit rendering engine in Azure app service, but it will work only from Basic or above hosting plans. This may throws this exception, if we deployed the app in free/shared hosting plans. Please refer below KB link, 

If you are using Run from package option, the reported issue may occur. So, can you please try the conversion without run from package option while deploying the app to azure app service.   

If still you are facing the same issue, kindly ensure all the files from QtBinaries folder is deployed in app service using console in Azure portal. Also, please share the details such as azure hosting plan, region, complete code snippet, input URL, etc., to check the issue in our side. It will be helpful for us to analyse and assist you further on this.  

Regards, 
Prakash V 



AD Alexandre Derveaux December 22, 2022 03:37 PM UTC

Hi everyone,


We have got the same issue with dot net core, blink and azure app service, so as proposed, we tried to use WebKit engine.

As explained in documentation we need to use the WebKit NuGet below :

Syncfusion.HtmlToPdfConverter.QtWebkit.Net.Core

Except that it is unlist from the NuGet gallery...

Why it's unlist from NuGet gallery ? I assume that WebKit is obsolete or something...

Hopefully, searching on this site, I've found a direct link to the package to NuGet website (luckily we can found a unlisted package with direct link)

https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.QtWebKit.Net.Core

I tried with this package on azure and it worked !

But this is not a long term solution because the NuGet package is unavailable and may be the next version will not using webkit anymore so we will be blocked.

To sum up :

Blink engine does not work with azure app service

WebKit is unavailable (QtWebKit is unlisted from NuGet gallery)

Is there another way to convert html to PDF with syncfusion with dotnet core 6 on azure app service ?

Thx




TI Tinh December 26, 2022 09:56 AM UTC

Hi everyone,

We already upgrade Syncfusion.HtmlToPdfConverter.QtWebKit.Net.Core ​to 20.3.0.58 version​However, we are having red warning on file after convert. 


So we used  Syncfusion.HtmlToPdfConvert.Blink instead for  Syncfusion.HtmlToPdfConverter.QtWebKit.Net.Core, but we are having issue:

MessageFailed to convert webpage

Exception:  Syncfusion.Pdf.PdfException: at Syncfusion.HtmlConverter.BlinkConverter.Convert (Syncfusion.HtmlConverter.Portable, Version=20.3600.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89) at Syncfusion.HtmlConverter.BlinkConverter.Convert (Syncfusion.HtmlConverter.Portable, Version=20.3600.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89) at Syncfusion.HtmlConverter.HtmlToPdfConverter.Convert (Syncfusion.HtmlConverter.Portable, Version=20.3600.0.58, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89)


Currently, we reverted and disabled webkit warning (​.DisableWebKitWarning = true) for resolve. Howerver, this is not a long term solution because we recieved the notify: The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.

Please help support for this issue.

References:

https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.QtWebKit.Net.Core/

Thank you !




SN Santhiya Narayanan Syncfusion Team December 27, 2022 01:42 PM UTC

We can use the Html to PDF converter with .NET Core library in Azure App Service Linux or Azure Functions Linux. The GDI limitation mentioned in this article is applicable for Azure App Service windows only. So, if you are using a Linux app service, you can use the converter with .NET Core API in Azure App Service Linux.


Please refer to the below links for more information,

Azure App Service Linux: https://www.syncfusion.com/kb/12909/how-to-convert-html-to-pdf-in-azure-app-service-linux-with-blink-rendering-engine

Azure Functions Linux: https://www.syncfusion.com/kb/12908/how-to-convert-html-to-pdf-using-blink-in-azure-functions-linux

Please refer below documentation page

https://help.syncfusion.com/file-formats/pdf/convert-html-to-pdf/troubleshooting





MW Michael Webb replied to Santhiya Narayanan December 29, 2022 09:56 PM UTC

We use .net core 3.1 (with Blazor) and Azure App Service (Windows), and so are unable to use the Syncfusion Html convertor (using Blink)... is it possible for us to use your webkit version somehow (for .net core)?  Or know of any other preferred non-Blink ways of converting HTML to a PDF?  Thanks!



SN Santhiya Narayanan Syncfusion Team December 30, 2022 11:26 AM UTC

You can install the Syncfusion.HtmlToPdfConverter.QtWebKit.Net.Core package in Package manager console by using below command,

NuGet\Install-Package Syncfusion.HtmlToPdfConverter.QtWebKit.Net.Core -Version 20.4.0.38




TA Tao May 12, 2023 09:47 AM UTC

Please advise on the  " The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.  The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore."



SN Santhiya Narayanan Syncfusion Team May 15, 2023 10:12 AM UTC

This is not a security issue. We have changed the default rendering engine to Blink from WebKit. So, we have unlisted the WebKit rendering engine specific packages. We are suggest you to try the Blink rendering engine. But if you are using Azure App Service windows, you can use WebKit packages. To provide backward compatibility we are publishing our old packages in NuGet.org for every release. 


Loader.
Up arrow icon