HTML to PDF Using ASP.NET Core in Linux Docker | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (180).NET Core  (28).NET MAUI  (227)Angular  (113)ASP.NET  (49)ASP.NET Core  (81)ASP.NET MVC  (87)Azure  (42)Black Friday Deal  (1)Blazor  (236)BoldSign  (14)DocIO  (24)Essential JS 2  (111)Essential Studio  (200)File Formats  (72)Flutter  (136)JavaScript  (226)Microsoft  (122)PDF  (83)Python  (1)React  (105)Streamlit  (1)Succinctly series  (131)Syncfusion  (964)TypeScript  (33)Uno Platform  (3)UWP  (3)Vue  (46)Webinar  (53)Windows Forms  (59)WinUI  (72)WPF  (163)Xamarin  (159)XlsIO  (38)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (11)Business intelligence  (55)Button  (4)C#  (164)Chart  (147)Chart of the week  (58)Cloud  (15)Company  (440)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (73)Development  (681)Doc  (7)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (7)Essential Tools  (13)Excel  (43)Extensions  (23)File Manager  (7)Gantt  (21)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (522)Mobile MVC  (9)OLAP server  (2)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (45)Performance  (13)PHP  (2)PivotGrid  (5)Predictive Analytics  (6)Report Server  (3)Reporting  (8)Reporting / Back Office  (9)Rich Text Editor  (12)Road Map  (12)Scheduler  (54)Security  (5)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (32)Solution Services  (4)Spreadsheet  (11)SQL  (15)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (113)UI  (406)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (628)What's new  (341)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)

HTML to PDF Conversion Using ASP.NET Core in Linux Docker

Docker is a lightweight and very popular container platform that packages an application with everything it needs to run, with the necessary code, system libraries, fonts, other supported libraries, or files. 

Visual Studio 2017 and Docker support building and running .NET applications using a Windows docker container and .NET Core application on Linux docker containers.

Syncfusion HTML to PDF converter can be easily integrated into any application with five simple lines of code. Using this library, you can turn an entire webpage into a PDF file. Or just convert a portion of the page. Your PDF will just look like the webpage you converted—it preserves all graphics, images, text, fonts, links, and the layout of the original HTML document or webpage.

Furthermore, Syncfusion HTML to PDF converter is available in Windows Forms, WPF, ASP.NET, ASP.NET MVC, and ASP.NET Core. In this post, I use ASP.NET Core in a Linux Docker container.

Seamlessly convert webpages and other complex HTML content to PDF with a comprehensive API set.


  • First, download HTML to PDF Linux from our download page. For this demo, I downloaded HTML to PDF for Linux. But you can just as easily download any other installer, like Mac and Windows.
Download HTML to PDF for Linux
Already installed Docker for Windows? Great! Now we need to create a new ASP.NET Core web application.
Create ASP.NET Core Project
  • Make sure to select ASP.NET Core 2.0, enable Docker support, and target the Linux OS.
Enable Docker in Visual Studio
  • Add the Syncfusion.HtmlConverter.NETStandard NuGet packages as a reference to your .NET Core project from the Syncfusion ASP.NET Core NuGet feed. For more information about adding a NuGet feed in Visual Studio and installing the NuGet package, refer to our documentation. You can also install this package from the NuGet package manager console by executing the following command.
> Install-Package Syncfusion.HtmlConverter.NETStandard -source
  • Extract the downloaded .zip file and refer the QtBinaries physical path to the WebKitPath from the WebKitConverterSettings class.

Can you show us some code?

Looking at some code is always a good idea to give more understanding.
//Initialize HTML to PDF converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
//Set WebKit path
htmlConverter.ConverterSettings.WebKitPath = Path.Combine(_hostingEnvironment.ContentRootPath, "QtBinaries");
//Convert URL to PDF
PdfDocument document = htmlConverter.Convert("");
MemoryStream ms = new MemoryStream();
//Save and close the PDF document

Include the below snippet in the docker file to install the dependent packages in the docker container.

FROM microsoft/aspnetcore:2.0 AS base
RUN apt-get update && apt-get -y install xvfb && apt-get -y install fontconfig && apt-get -y install libssl1.0-dev && apt-get -y install libx11-dev libx11-xcb-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-render-util0-dev libxcb-render0-dev libxcb-shm0-dev libxcb-util0-dev libxcb-xfixes0-dev libxcb-xkb-dev libxcb1-dev libxfixes-dev libxrandr-dev libxrender-dev

Build and run the sample in the docker, it will pull the Linux docker image from the docker hub and run the project. Now, the webpage will open in the browser. Click Convert to PDF to convert the Google webpage to a PDF.

This sample is made as simple as possible for converting a webpage to PDF.

Join thousands of developers who rely on Syncfusion for their PDF needs. Experience the difference today!


Whether you need to convert a URL, webpage, or HTML string to PDF in the docker containers, the Syncfusion HTML to PDF converter libraries make work short for .NET developers. With our libraries, we can even convert SVG and MHTML to PDF. There are advanced features such as form authentication, header, footer, table of contents, and automatic bookmark hierarchy based on heading style. Take a moment to peruse the documentation, where you’ll find other options and features, all with accompanying code examples.

As always, your feedback is highly appreciated, so please do reach out in our comments. You can also contact us through our support forum or Direct-Trac. We are happy to assist you!

If you’re already a Syncfusion user, you can download the product setup on Direct-Trac. If you’re not yet a Syncfusion user, you can download a free, 30-day trial on our website.

If you like this blog post, we think you’ll also like the following free e-books:

PDF Succinctly
Linux Succinctly
ASP.NET Core Succinctly
.NET Core Succinctly


Share this post:

Comments (1)

This is not working with the .net core 3.1 version. Showing the below error.
Package libssl1.0-dev is not available, but is referred to by another package. E: Package ‘libssl1.0-dev’ has no installation candidate

Comments are closed.

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed