2X faster development
The ultimate ASP.NET Core UI toolkit to boost your development speed.
The Syncfusion HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML to PDF using C#. It is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage. Using this library, you can convert a HTML to PDF in Linux docker container. Steps to convert HTML to PDF in Linux docker container:
// [C# Code] //To get content root path of the project private readonly IHostingEnvironment _hostingEnvironment; public HomeController(IHostingEnvironment hostingEnvironment) { _hostingEnvironment = hostingEnvironment; } public ActionResult ExportToPDF() { //Initialize HTML to PDF converter HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); WebKitConverterSettings settings = new WebKitConverterSettings(); //Set WebKit path settings.WebKitPath = Path.Combine(_hostingEnvironment.ContentRootPath, "QtBinariesLinux"); //Assign WebKit settings to HTML converter htmlConverter.ConverterSettings = settings; //Convert URL to PDF PdfDocument document = htmlConverter.Convert("http://www.google.com"); MemoryStream stream = new MemoryStream(); //Save and close the PDF document document.Save(stream); return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf, "Sample.pdf"); }
A complete work sample for converting a HTML to PDF in Linux docker container can be downloaded from HTMLtoPDF_LinuxDocker.zip. Take a moment to peruse the documentation, where you can find other WebKit, Blink and IE rendering engines supported by Syncfusion .NET PDF library for converting HTML pages to PDF document along with respective customization options and features. Click here to explore the rich set of Syncfusion Essential PDF features. An online sample link to convert HTML to PDF. |
2X faster development
The ultimate ASP.NET Core UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.
Some observations: