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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to convert HTML to PDF in Azure Functions 2.0

Platform: ASP.NET Core |
Control: PDF

Syncfusion HTML to PDF for .NET Core used to convert web pages, and HTML to PDF. Using this library, you can convert any HTML strings or URL or web pages to PDF in Azure Functions 2.0.

In this tutorial, we will illustrate the conversion of HTML to PDF using C# with advanced WebKit rendering engine. In addition, our HTML to PDF converter will work seamlessly in various platforms like Azure cloud or web apps, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and MacOS.

Steps to convert HTML to PDF in Azure Functions 2.0

  1. Create an Azure Functions projects.

Create Azure function project

  1. Select framework to Azure Functions V2 (.NET Core) and select HTTP triggers as follows.

Select Http trigger

  1. Install the Syncfusion.HtmlToPdfConverter.QtWebKit.Net.Core NuGet package as a reference to the project.

install latest QtWebkit Net core

  1. Copy the QtBinariesWindows folder from the NuGet package installed location and paste it into the application folder, which contains HTMLtoPDFV20.csproj

copy Qtbinaries from nuget location


pasted the binaries folder inside the project location

  1. Set Copy to Output Directory property to Copy if newer to all the QtWebKit binaries.

Copy if newer to QtBinaries

  1. Include the following namespace in Functions1.cs file to convert the HTML to PDF using C#.


using Syncfusion.HtmlConverter;
using Syncfusion.Pdf;


  1. Add the following code snippet in Function1 class to convert HTML to PDF in Azure Functions V2.
    string name = req.Query["url"];
    //Initialize HTML to PDF converter  
    HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
    WebKitConverterSettings settings = new WebKitConverterSettings();
    //Set WebKit path
    settings.WebKitPath = Path.Combine(executionContext.FunctionAppDirectory, "QtBinariesWindows");
    //Assign WebKit settings to HTML converter 
    htmlConverter.ConverterSettings = settings;
    //Convert URL to PDF 
    PdfDocument document = htmlConverter.Convert(name);
    MemoryStream ms = new MemoryStream();
    //Save the PDF document  
    ms.Position = 0;
    HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
    response.Content = new ByteArrayContent(ms.ToArray());
    response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
        FileName = "HTMLToPDFAzure.pdf"
    response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/pdf");
    return response;


  1. Right click the project and select publish. Create a new profile in the publish window.


When creating a publish target, please unselect the Run from package file option. So that, you can avoid the conversion failure due to the permission restrictions.

If you run from package file option, then the function permission becomes read only. But, the WebKit converter requires read/write/execute permission to perform the conversion. Refer to the following screenshot,


Creating a new profile. Unselect run from package file to avoid conversion failure.

  1. Create App service using Azure subscription and select a hosting plan.

Create App service

  1. HTML to PDF conversion will work from basic hosting plan (B1). So, select the hosing plan to B1 or greater and publish. HTML to PDF conversion will not work if the hosting plan is Consumption.

Configure Hosting plan

  1. Once the profile is created, click the publish button.


  1. Now, go to Azure portal and select the Functions Apps. After running the service, click the Get function URL -> Copy. Paste the same in the browser. In this example, need to pass the webpage URL in the query string, which needs to be converted to PDF.



output pdf document image

A complete working sample can be downloaded from HTMLToPDF_AzureFunctions2.0

Convert secured or https sites to PDF in Azure Functions 2.0

When converting HTTPS sites, empty PDF may generate due to missing of the OPENSSL assemblies in Azure website. To convert HTTPS sites, the converter requires OPENSSL assemblies. By default, some Azure websites do not have the OPENSSL assemblies. So, these assemblies should be added to the website explicitly.

You can get the OPENSSL assemblies from here.

  1. Copy the OPENSSL assemblies into the QtBinariesWindows folder. Refer below screenshot,

copy Openssl assemblies into binaries folder

  1. Then set the copy to output directory as “Copy if newer” for all the files under QtBinariesWindows folder.



2X faster development

The ultimate ASP.NET Core UI toolkit to boost your development speed.
You must log in to leave a comment
Miguel Goicochea
Jul 04, 2019

Hello I tried following this example and while it works well locally (the report takes 3 minutes to generate). However, when I publish to Azure I get a timeout after the function has been running for less than 4 minutes (3min 50s). The azure function is using a dedicated app plan and I have had no issues when running other products I have been evaluating for a longer period, so I am not sure if I am missing any settings on the converter.

Gowthamraj Kumar [Syncfusion]
Jul 04, 2019

Hi Miguel,

The converter may throws the exception under Consumption/Free/Shared hosting plans on Azure. Please make sure you are not using the mentioned hosting plans to publish on Azure environment. Due to the access restrictions and limitation of these hosting plan, it prevents the loading of the browser process. So, the conversion will be failed or timeout in the Consumption/Free/Shared hosting plans on Azure environment. Other hosting plans does not have the restriction for loading the browser process.

If still you are facing the same error, kindly contact us through our Direct Trac


Gowthamraj K

Underwood Studio
May 01, 2021

The OPENSSL assemblies link above doesn't work. It just tosses you to an "Access Denied" error page on S3. Can that link be updated?

Gowthamraj Kumar [Syncfusion]
May 04, 2021

Hi Underwood,

Sorry for the inconvenience caused.

We have updated the proper OPENSSL assemblies link in this KB article. Now you can download the assemblies from below link,

OPENSSL: https://www.syncfusion.com/downloads/support/directtrac/general/ze/OPENSSL-1821714558

Please refer the below link for more details about OPENSSL,

UG: https://help.syncfusion.com/file-formats/pdf/convert-html-to-pdf/webkit#openssl

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


Gowthamraj K

jay patadia
Aug 06, 2021

On my local machine, it is working fine. But, when deploying to Azure It throws an error, HTML conversion failed.

I am hosting it on the b1 plan, I have also unchecked the run from the package file option.

Can you help me to find out what is the issue here?

Thank you,

Gowthamraj Kumar [Syncfusion]
Aug 09, 2021

Hi 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.


  4. As we said earlier, QtBinaries assemblies are not copied properly while publish to Azure functions.

  5. So, we need to manually copy all the assemblies from azure portal.

  6. 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.

  7. 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.

  2. 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.


  2. Now try the conversion from Azure function URL.

  3. We need to copy this assemblies for the first time only.


Gowthamraj K

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile