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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to install WebKit HTML converter using NuGet package manager

Platform: ASP.NET MVC |
Control: PDF |
Published Date: July 26, 2019 |
Last Revised Date: July 30, 2019

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:

  1. Create a new ASP.NET MVC application project. Create a MVC project. Create MVC template
  2. Install the Syncfusion.HtmlToPdfConverter.QtWebKit.AspNet.Mvc5  NuGet package as a reference to your .NET Framework applications from NuGet.org. Install packages from NuGet manager.
  3. Copy the QtBinaries folder from the installed HtmltoPdfConverter package and paste it into the folder, which contains the HTMLtoPDF.csproj file. NuGet location pathpaste the Qtbinaries folder to project location.
  4. Then, include the QtBinaries folder in a project and set Copy to output directory as copy always for all the QtBinaries (All files including inner folders and files) assemblies. Include the QtBinaries folder to a project. Set Copy always to QtBinaries
  5. Add a button to convert HTML to PDF in index.cshtml.
    @using (Html.BeginForm("ExportToPDF", "Home", FormMethod.Post))
    {
        <input type="submit" value="Convert HTML to PDF" />
    }
    

 

  1. Include the following namespaces and code snippet for converting HTML to PDF.

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

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.
ADD COMMENT
You must log in to leave a comment

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
Live Chat Icon