Articles in this section
Category / Section

How to convert HTML to PDF in ASP.NET Core Mac

1 min read

Syncfusion HTML to PDF for .NET used to convert webpages, SVG, MHTML, and HTML to PDF. Using this library, you can convert HTML to PDF in ASP.NET Core application using .Net Standard 2.0.

Minimum product version:

Minimum .NET core version: 2.0.0

The following assemblies or NuGet package is required for converting HTML to PDF in ASP.NET Core Mac.

Assemblies required:

  • Syncfusion.Compression.Portable.dll
  • Syncfusion.Pdf.Portable.dll
  • Syncfusion.HtmlConverter.Portable.dll
  • QtBinaries

You can get all the previously mentioned assemblies, QtBinaries, and working samples by installing the HTML converter installer for Mac available in the following link.

HTML converter Mac (pkg file):


Install the Syncfusion.HtmlToPdfConverter.QtWebKit.Net.Core NuGet package as reference to your .NET Core application from The NuGet package contains QtBinaries for all platforms (Windows, Linux and Mac). Copy the QtBinariesMac folder from the NuGet package installed location and paste it into your application folder to use it for conversion.

NuGet Installed location: /.nuget/packages/

Use the following code snippet to convert HTML to PDF in ASP.NET Core Mac.

// [C# Code]
//To get content root path of the project
private readonly IHostingEnvironment _hostingEnvironment;
public HomeController(IHostingEnvironment hostingEnvironment)
   _hostingEnvironment = hostingEnvironment;
public IActionResult ExportToPDF()
 //Initialize HTML to PDF converter 
 HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
 WebKitConverterSettings settings = new WebKitConverterSettings();
 //Set WebKit path
 settings.WebKitPath = Path.Combine(_hostingEnvironment.ContentRootPath, "QtBinariesMac");
 //Assign WebKit settings to HTML converter
 htmlConverter.ConverterSettings = settings;
 //Convert URL to PDF
 PdfDocument document = htmlConverter.Convert("");
 MemoryStream stream = new MemoryStream();
 return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf, "Output.pdf");


A complete working sample can be downloaded from

Take a moment to peruse the documentation for Converting HTML to PDF, where you will find various options for URL to PDF, HTML string to PDF, and hyperlinks.

Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment