2X faster development
The ultimate ASP.NET MVC 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. You can install the required assemblies and binaries in the .NET Framework application by using the NuGet package manager. Refer to this documentation link for installing NuGet packages. Steps to install WebKit HTML converter using NuGet package manager:
C# using Syncfusion.HtmlConverter; using Syncfusion.Pdf; using System.IO;
public ActionResult ExportToPDF() { //Initialize HTML to PDF converter HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit); WebKitConverterSettings settings = new WebKitConverterSettings(); //Set WebKit path settings.WebKitPath = Server.MapPath("~/QtBinaries/"); //Assign WebKit settings to HTML converter htmlConverter.ConverterSettings = settings; //Convert a URL to PDF with HTML converter PdfDocument document = htmlConverter.Convert("http://www.google.com"); //Save the PDF document MemoryStream stream = new MemoryStream(); document.Save(stream); return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf, "HTMLtoPDF.pdf"); }
A complete working sample can be downloaded from HTMLtoPDF.zip. By executing the program, you will get the PDF file as follows. Take a moment to peruse the documentation, where you will find other options like Html string to PDF, partial webpage to PDF, Html to single PDF page, and Html to PDF conversion using IE Rendering with code examples. Click here to explore the rich set of Syncfusion Essential PDF features. An online sample link to Convert Html To PDF document. Note: Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.
|
2X faster development
The ultimate ASP.NET MVC UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.